Skip to main content

Global Agents

Global agents are AI specialists that you can execute from anywhere on your system, just like any other terminal command. Instead of navigating to a project directory to use an agent, you can invoke it from any location.

What are Global Agents?

Global agents transform Claude Code agents into standalone CLI commands:
  • Regular Agent: Only works in the directory where installed (.claude/agents/)
  • Global Agent: Works from any directory, like npm, git, or docker

System-Wide Access

Run from any directory without navigating to project

Auto Context Detection

Automatically detects project type and includes relevant files

Standalone Execution

No need for Claude Code to be open

Script Integration

Use in npm scripts, CI/CD, and shell scripts

How Global Agents Work

Creating Global Agents

Basic Creation

Output:
Now you can run from anywhere:

With Category Path

If the agent name is ambiguous, use the full category path:

Creating Multiple Global Agents

Create several agents at once:

Using Global Agents

Basic Usage

Examples:

Auto-Context Detection

Global agents automatically detect your project type and include relevant files:
The agent automatically:
  • Detects React project (from package.json)
  • Includes src/, components/, pages/ directories
  • Understands React patterns and conventions
  • Can read files using the Read tool
Supported Project Types:
  • JavaScript/Node: Detects from package.json, includes src/, lib/, components/
  • Python: Detects from requirements.txt or pyproject.toml, includes *.py files
  • Go: Detects from go.mod, includes *.go, cmd/, internal/, pkg/
  • Rust: Detects from Cargo.toml, includes src/, Cargo.toml
  • React/Vue/Next.js: Framework detection from dependencies

Explicit File Selection

Override auto-detection by specifying files:

Directory Targeting

Disable Auto-Detection

For general advice without project context:

Verbose Mode

See what the agent is doing:
Outputs:

Managing Global Agents

List Installed Agents

Output:

Remove an Agent

Output:

Update an Agent

Fetch the latest version from GitHub:
Output:

Installation Locations

If you have write access to /usr/local/bin, agents are installed there:
Advantages:
  • Immediately available in PATH
  • No shell configuration needed
  • Works in all terminals and IDEs

User Directory (Fallback)

If system directory is not writable, uses user directory:
⚠️ Requires PATH Setup: The CLI automatically adds to your shell config:
~/.bashrc or ~/.zshrc
Restart your terminal or run:

Advanced Usage

In npm Scripts

Add global agents to package.json:
package.json

In Shell Scripts

Create automation scripts:
pre-commit.sh

In CI/CD Pipelines

In Docker Containers

Custom Global Agents

You can create custom global agents by:
  1. Creating a custom agent in .claude/agents/
  2. Publishing to GitHub
  3. Installing as global agent

Troubleshooting

Command Not Found

If you get command not found after creating a global agent:
Solutions:
  1. Check PATH:
  2. Add to PATH manually:
  3. Use absolute path:

Permission Denied

Solution: Make executable:

Claude CLI Not Found

Global agents require Claude CLI:
Solution: Install Claude CLI:

Agent File Not Found

Solution: Recreate the global agent:

Context Detection Not Working

If the agent doesn’t detect your project:
Solution: Manually specify files:

Best Practices

1. Name Agents Descriptively

✅ Good:
❌ Bad:

2. Use for Specialized Tasks

Global agents work best for:
  • Security audits
  • Code reviews
  • Documentation generation
  • Performance analysis
  • Compliance checks
Not ideal for:
  • General chatting
  • Multi-step projects
  • Interactive sessions

3. Combine with Shell Aliases

~/.bashrc

4. Create Agent Sets

Install related agents together:

5. Document in Team README

README.md

Next Steps

Installing Components

Learn about regular component installation

Batch Installation

Install multiple components at once

Workflows

Create reusable installation workflows

Component Browser

Browse all available agents