agent

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 18, 2026 License: MIT Imports: 5 Imported by: 0

README

agent

import "github.com/gechr/x/agent"

Package agent detects AI coding agents hosting the process.

Index

Constants

Environment variables consulted by Is and Detect.

const (
    // EnvAgent is the proposed cross-tool convention
    // (https://github.com/agentsmd/agents.md/issues/136), set either to the
    // agent's name (e.g. `goose`, `amp`) or a truthy token like `1`.
    EnvAgent = "AGENT"
    // EnvAIAgent is the more specific variant used by Vercel's detection
    // tooling; consulted with the same semantics as [EnvAgent].
    EnvAIAgent = "AI_AGENT"
)

Recognized AI coding agent names, as returned by Detect.

const (
    Amp      = "amp"
    Claude   = "claude"
    Cline    = "cline"
    Codex    = "codex"
    Cursor   = "cursor"
    Gemini   = "gemini"
    Goose    = "goose"
    OpenCode = "opencode"
    Replit   = "replit"
)

func Detect

func Detect() string

Detect returns the name of the AI coding agent hosting the process, or empty if there is none or it cannot be identified. A named AGENT / AI_AGENT value is returned verbatim (lowercased), so agents unknown to this package still identify themselves; a bare truthy token like AGENT=1 signals presence without identity, so Detect falls through to the marker variables and may return empty even though Is reports true.

func Is

func Is() bool

Is reports whether the process appears to be running under an AI coding agent. Detection is best-effort, based on environment variables set by the hosting agent: the cross-tool AGENT / AI_AGENT convention first, then agent-specific markers (CLAUDECODE, CODEX_SANDBOX, CURSOR_AGENT, ...). A falsy AGENT / AI_AGENT value (0, false, no, off) is an explicit opt-out and reports false even when a marker variable is present, mirroring the CI=false escape hatch.

func IsKnown

func IsKnown(name string) bool

IsKnown reports whether name matches a known AI coding agent.

Example
fmt.Println(agent.IsKnown(agent.Claude))
fmt.Println(agent.IsKnown("some-future-agent"))

Output:

true
false

func Known

func Known() []string

Known returns the set of recognized AI coding agent names.

Example
fmt.Println(agent.Known())

Output:

[amp claude cline codex cursor gemini goose opencode replit]

Documentation

Overview

Package agent detects AI coding agents hosting the process.

Index

Examples

Constants

View Source
const (
	// EnvAgent is the proposed cross-tool convention
	// (https://github.com/agentsmd/agents.md/issues/136), set either to the
	// agent's name (e.g. `goose`, `amp`) or a truthy token like `1`.
	EnvAgent = "AGENT"
	// EnvAIAgent is the more specific variant used by Vercel's detection
	// tooling; consulted with the same semantics as [EnvAgent].
	EnvAIAgent = "AI_AGENT"
)

Environment variables consulted by Is and Detect.

View Source
const (
	Amp      = "amp"
	Claude   = "claude"
	Cline    = "cline"
	Codex    = "codex"
	Cursor   = "cursor"
	Gemini   = "gemini"
	Goose    = "goose"
	OpenCode = "opencode"
	Replit   = "replit"
)

Recognized AI coding agent names, as returned by Detect.

Variables

This section is empty.

Functions

func Detect

func Detect() string

Detect returns the name of the AI coding agent hosting the process, or empty if there is none or it cannot be identified. A named `AGENT` / `AI_AGENT` value is returned verbatim (lowercased), so agents unknown to this package still identify themselves; a bare truthy token like `AGENT=1` signals presence without identity, so Detect falls through to the marker variables and may return empty even though Is reports true.

func Is

func Is() bool

Is reports whether the process appears to be running under an AI coding agent. Detection is best-effort, based on environment variables set by the hosting agent: the cross-tool `AGENT` / `AI_AGENT` convention first, then agent-specific markers (`CLAUDECODE`, `CODEX_SANDBOX`, `CURSOR_AGENT`, ...). A falsy `AGENT` / `AI_AGENT` value (`0`, `false`, `no`, `off`) is an explicit opt-out and reports false even when a marker variable is present, mirroring the `CI=false` escape hatch.

func IsKnown

func IsKnown(name string) bool

IsKnown reports whether `name` matches a known AI coding agent.

Example
package main

import (
	"fmt"

	"github.com/gechr/x/agent"
)

func main() {
	fmt.Println(agent.IsKnown(agent.Claude))
	fmt.Println(agent.IsKnown("some-future-agent"))
}
Output:
true
false

func Known

func Known() []string

Known returns the set of recognized AI coding agent names.

Example
package main

import (
	"fmt"

	"github.com/gechr/x/agent"
)

func main() {
	fmt.Println(agent.Known())
}
Output:
[amp claude cline codex cursor gemini goose opencode replit]

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL