Skip to main content

agenthint banner

agenthint

CI Release npm crates.io PyPI License GitHub Repo stars

Detect AI agent runtimes and adapt CLI output.

agenthint is a small detection spec, CLI, and multi-language library for developer tools that want to know when they are probably being run by an AI agent such as Codex, Claude Code, Cursor, Gemini CLI, Aider, or another automated coding environment.

Use it to choose better defaults for agent-driven runs: structured output, quiet logs, no spinners, no pagers, no interactive prompts, and clearer diagnostics.

Detection is advisory. agenthint is for user experience decisions, not authentication, authorization, sandboxing, or policy enforcement.

Quick Start

Install the CLI:

npm install -g agenthint
# or
cargo install agenthint
# or
python3 -m pip install agenthint

Use its exit code in scripts:

if agenthint >/dev/null; then
  exec my-tool --json --no-progress --no-pager "$@"
else
  exec my-tool "$@"
fi

Prefer the explicit convention when you control the agent or wrapper:

AI_AGENT=codex my-tool
AI_AGENT=claude-code my-tool
AI_AGENT=my-custom-agent my-tool

Why

Humans and agents often need different CLI behavior.

Humans often prefer Agents often prefer
Colors, spinners, prompts Stable, parseable output
Pagers and browser launches Non-interactive execution
Decorative progress UI Line-oriented diagnostics
Friendly summaries Explicit sections and exit codes

agenthint gives tools a shared, explainable way to switch modes without each project inventing its own agent detection logic.

CLI

agenthint             # exit 0 if an agent is likely detected, otherwise 1
agenthint --json      # print the structured detection result
agenthint --explain   # print a short human-readable explanation
agenthint doctor      # print detection details and setup advice
agenthint doctor --json
agenthint init codex  # print the recommended AI_AGENT value
agenthint --version   # print the version

Example JSON:

{
  "isAgent": true,
  "agent": "codex",
  "confidence": 0.92,
  "signals": ["env:CODEX_CI", "env:CODEX_THREAD_ID"]
}

Exit codes:

Code Meaning
0 Agent runtime likely detected
1 Agent runtime not detected
2 Invalid usage or detection error

Setup-only commands such as agenthint init <agent> exit 0.

Libraries

TypeScript

import { detectAgent } from "agenthint";

const result = detectAgent();

if (result.isAgent) {
  // Prefer structured, quiet, non-interactive output.
}

Rust

use agenthint::detect_agent;

let result = detect_agent();

if result.is_agent {
    // Prefer structured, quiet, non-interactive output.
}

Python

from agenthint import detect_agent

result = detect_agent()

if result.is_agent:
    # Prefer structured, quiet, non-interactive output.
    pass

Install

npm

npm install -g agenthint
agenthint --json

crates.io

cargo install agenthint
agenthint --json

PyPI

python3 -m pip install agenthint
agenthint --json

Native binary

curl -fsSL https://raw.githubusercontent.com/forjd/agenthint/main/install.sh | sh

The install script downloads the latest agenthint-v* GitHub Release asset for your platform and verifies it against SHA256SUMS.

Override the install directory or version:

AGENTHINT_INSTALL_DIR=/usr/local/bin sh install.sh
AGENTHINT_VERSION=agenthint-vX.Y.Z sh install.sh
AGENTHINT_ALLOW_MISSING_CHECKSUM=1 sh install.sh

Detection Model

Every detection result includes:

Field Description
isAgent Whether an agent runtime is likely detected
agent Known or custom agent name, when available
confidence A number from 0 to 1
signals Diagnostic signal names, never secret values

Detection priority:

  1. AGENTHINT_DISABLE
  2. AGENTHINT_FORCE (optionally named via AGENTHINT_AGENT)
  3. Explicit AI_AGENT
  4. Known environment signals
  5. Documented filesystem signals
  6. Low-confidence parent process signals
  7. Low-confidence stdio hints

Known agents include Codex, Claude Code, Cursor, Gemini CLI, Aider, Augment CLI, AMP, OpenCode, OpenClaw, GitHub Copilot, Replit, Devin, Google Antigravity, Pi, Kiro CLI, Windsurf, Cline, Roo Code, Kilo Code, Mistral Vibe, v0, and Cowork.

Some signals are weak. For example REPL_ID is present in every Replit workspace, including human-driven sessions, so it reports a low confidence. Exit-code consumers that want to avoid false positives can read confidence from agenthint --json and apply their own threshold.

Custom agents are supported through any non-empty AI_AGENT value.

Docs

Principles

  • Prefer explicit AI_AGENT support over heuristics.
  • Return confidence, not false certainty.
  • Print signal names, not environment variable values.
  • Keep filesystem probes documented and configurable.
  • Keep requested machine-readable output quiet and stable.
  • Treat detection as a hint, never as a security boundary.

Development

mise install
mise exec -- npm run check

Useful scripts:

npm run build
npm run format
npm run lint
npm run test
npm run check
cargo test --workspace

Contributions are welcome. Please keep detection results explainable, avoid printing secret-bearing environment values, and update the docs when adding or changing signals.

Metadata

Release files for agenthint 0.5.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for agenthint 0.5.0
File Size Uploaded
agenthint-0.5.0.tar.gz 13.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for agenthint 0.5.0
File Interpreter ABI Platform
agenthint-0.5.0-py3-none-any.whl Python 3 none any Details

Total release size: 25.2 kB

Release files / agenthint-0.5.0.tar.gz

Download URL agenthint-0.5.0.tar.gz
Size 13.4 kB
Tags Source
SHA-256 checksum
How to use checksums
aacab5d2719db00b92c48949784cb53512467dd699caeed94867d3cc23813b19
BLAKE2b-256 checksum
How to use checksums
cb816d37a03976315760db5260281ae5a873bb0f6b479207e7bf7f8448cad2f6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 12, 2026.

Transparency log

Release files / agenthint-0.5.0-py3-none-any.whl

Download URL agenthint-0.5.0-py3-none-any.whl
Size 11.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fac3f9d0ae89f139bf55a15ebda204616624fefee140ce77135a15306c4fb339
BLAKE2b-256 checksum
How to use checksums
6599aa941934678c703a8f8bd6a29dff28773956a8457546833895db96cb2f82
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 12, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.5.0 This release

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page