Skip to content

Agents

Agent packages define autonomous workflows with system prompts, tool access, and model preferences. Claude Code, Cursor, and Codex all support agents natively but with different feature sets and file formats. This page documents how each tool discovers, loads, and runs agents.

For general information about agent packages, see Agent package type. For the generic setup mechanism, see Tool Setup Explained.

Claude Code has full native support for agents (called “subagents”). Each subagent runs in its own context window with a custom system prompt, specific tool access, and independent permissions.

Reference: Claude Code subagents documentation

Claude Code discovers agents from multiple locations, with higher-priority locations winning when names conflict:

LocationScopePriority
Managed settingsOrganization-wide1 (highest)
--agents CLI flagCurrent session2
.claude/agents/Current project3
~/.claude/agents/All your projects (user-level)4
Plugin agents/ directoryWhere plugin is enabled5 (lowest)

APKG writes agent packages to .claude/agents/ (project scope).

Claude Code supports multiple directory layouts. All three of the following produce the same result — an agent named test-agent:

.claude/agents/test-agent.md
.claude/agents/test-agent/test-agent.md
.claude/agents/@sheplu/test-agent/test-agent.md

The subfolder approach is what APKG uses. When you install @sheplu/test-agent, APKG creates:

.claude/agents/@sheplu/test-agent/test-agent.md

Claude Code resolves the agent name from the name field in frontmatter, not from the file path.

Markdown with YAML frontmatter. The frontmatter defines configuration; the body becomes the system prompt.

---
name: research-agent
description: Researches a topic and produces a structured report
tools: Read, Grep, Glob, WebSearch, WebFetch
model: sonnet
---
You are a research agent. When asked to research a topic:
1. Search for authoritative sources.
2. Read and extract key information.
3. Synthesize findings into a structured report with sources.
FieldRequiredDescription
nameYesUnique identifier (lowercase letters and hyphens)
descriptionYesWhen Claude should delegate to this agent — be specific so Claude knows when to use it
toolsNoComma-separated list of tools the agent can use. Inherits all tools if omitted
disallowedToolsNoTools to deny, removed from inherited or specified list
modelNoModel to use: sonnet, opus, haiku, a full model ID, or inherit (default)
permissionModeNoPermission mode: default, acceptEdits, auto, dontAsk, bypassPermissions, plan
maxTurnsNoMaximum agentic turns before the agent stops
skillsNoSkills to preload into the agent’s context at startup
mcpServersNoMCP servers available to this agent
hooksNoLifecycle hooks scoped to this agent
memoryNoPersistent memory scope: user, project, or local
backgroundNoIf true, always run as a background task
effortNoEffort level: low, medium, high, max
isolationNoSet to worktree for an isolated git worktree
colorNoDisplay color in the UI: red, blue, green, yellow, purple, orange, pink, cyan
initialPromptNoAuto-submitted as the first user turn when running as main session agent

Claude Code delegates to agents automatically based on the description field. Users can also:

  • Name the agent in natural language: “Use the research-agent to look into this.”
  • @-mention: @"research-agent (agent)" guarantees delegation.
  • Run as main agent: claude --agent research-agent starts a session using this agent’s prompt and tools.
  • Agents run in their own context window — they don’t consume the main conversation’s context.
  • Agents can run in the foreground (blocking) or background (concurrent).
  • Agents support persistent memory across conversations.
  • Agents cannot spawn other subagents (no nesting).
  • Agents support lifecycle hooks (PreToolUse, PostToolUse, Stop).
  • Agents can scope MCP servers — connect an MCP server only when the agent runs.

Cursor supports agents natively. It discovers agent definition files from multiple directories, including cross-tool compatibility with Claude Code and Codex.

Reference: Cursor subagents documentation

Cursor reads agents from these directories:

LocationNotes
.cursor/agents/Cursor’s native agents directory
.claude/agents/Cross-compatible with Claude Code
.codex/agents/Cross-compatible with Codex

When you configure defaultSetup.cursor, APKG installs agents into .cursor/agents/ — the native directory for Cursor. Cursor’s cross-tool discovery also means that agents installed into .claude/agents/ or .codex/agents/ by other tools are automatically available in Cursor without extra configuration.

Like Claude Code, Cursor supports both flat files and subfolders. All of the following produce the same result:

.cursor/agents/test-agent.md
.cursor/agents/test-agent/test-agent.md
.cursor/agents/@sheplu/test-agent/test-agent.md

APKG uses the scoped subfolder layout. When you install @sheplu/test-agent with Cursor configured, APKG creates:

.cursor/agents/@sheplu/test-agent/test-agent.md

Markdown with YAML frontmatter, same as Claude Code.

---
name: research-agent
description: Researches a topic and produces a structured report
tools: Read, Grep, Glob
---
You are a research agent. Search for information and synthesize
findings into a structured report.

Cursor supports a subset of the frontmatter fields that Claude Code uses:

FieldSupportedDescription
nameYesAgent identifier
descriptionYesWhen to delegate to this agent
toolsYesTools the agent can use
modelPartialCursor uses its own model selection; this field may be ignored
disallowedToolsNoNot supported
permissionModeNoNot supported — Cursor manages permissions independently
maxTurnsNoNot supported
skillsNoNot supported
mcpServersNoNot supported
hooksNoNot supported
memoryNoNot supported
backgroundNoNot supported
isolationNoNot supported

Cursor delegates to agents based on the description field, similar to Claude Code. Users can also invoke agents explicitly through Cursor’s agent picker UI.

  • Cross-tool discovery: Cursor reads from .claude/ and .codex/ in addition to .cursor/, making it the most compatible tool for mixed-tool teams.
  • Fewer frontmatter fields: Advanced features like hooks, mcpServers, memory, isolation, and permissionMode are not supported.
  • No background execution: Agents always run in the foreground.

Codex supports agents natively but uses TOML instead of Markdown for agent definitions. This is a key difference from Claude Code and Cursor.

Reference: Codex subagents documentation

Codex reads agents from two directories:

LocationScope
.codex/agents/Current project
~/.codex/agents/All your projects (user-level)

Codex does not read from .claude/agents/ or .cursor/agents/. Agent packages must be installed into .codex/agents/ to be available in Codex.

TOML — not Markdown. Each .toml file defines a single agent.

name = "research-agent"
description = "Researches a topic and produces a structured report."
model = "o3"
model_reasoning_effort = "medium"
sandbox_mode = "read-only"
developer_instructions = """
You are a research agent. When asked to research a topic:
1. Search for authoritative sources.
2. Read and extract key information.
3. Synthesize findings into a structured report with sources.
Always cite your sources. Do not fabricate information.
"""
FieldRequiredDescription
nameYesAgent identifier
descriptionYesWhen Codex should spawn this agent
developer_instructionsYesCore behavioral instructions (equivalent to the system prompt body in Markdown agents)
modelNoModel to use. Inherits from parent session if omitted
model_reasoning_effortNoReasoning level (e.g. "medium")
sandbox_modeNoExecution permissions: "read-only" or "workspace-write". Inherits from parent if omitted
nickname_candidatesNoArray of display names for spawned instances
mcp_serversNoMCP servers available to this agent
skills.configNoSkill configurations

Codex spawns agents only when you explicitly ask in natural language — there is no @-mention syntax or dedicated UI picker like in Claude Code or Cursor. You reference agents by name in your prompt:

“Have research-agent investigate the authentication flow and summarize findings.”

“Spawn one agent per point, wait for all of them, and summarize the result.”

Codex will not automatically delegate to an agent based on its description. You must ask for it. Once spawned, you can manage active agents with the /agent CLI command to switch between threads and inspect progress.

Codex includes three built-in agents:

AgentPurpose
defaultGeneral-purpose fallback
workerExecution-focused tasks
explorerRead-heavy exploration

Custom agents with matching names take precedence over built-ins.

Subagent behavior can be tuned in the main config under [agents]:

SettingDefaultDescription
agents.max_threads6Maximum concurrent agent threads
agents.max_depth1Maximum nesting depth
agents.job_max_runtime_secondsPer-worker timeout for batch jobs
  • TOML, not Markdown: Agent definitions use TOML with developer_instructions instead of a Markdown body.
  • No cross-tool discovery: Codex only reads from .codex/agents/, not from .claude/ or .cursor/.
  • sandbox_mode instead of tools/permissionMode: Codex uses "read-only" or "workspace-write" rather than listing individual tools.
  • Nesting supported: Codex supports agent nesting up to max_depth (default 1), unlike Claude Code where subagents cannot spawn other subagents.
  • No hooks, memory, isolation, or background fields.

When you install an agent package, APKG writes definition files into the tool’s agents directory based on your configured tool:

ToolOutput pathFormat
Claude Code.claude/agents/@<scope>/<name>/Markdown
Cursor.cursor/agents/@<scope>/<name>/Markdown
Codex.codex/agents/@<scope>/<name>/TOML

Each tool gets its own native directory. If you use multiple tools, enable each in your config (e.g. defaultSetup.claude-code and defaultSetup.cursor). Cursor’s cross-tool discovery also picks up agents from .claude/agents/, so agents installed for Claude Code are visible in Cursor as well.

If the agent package contains no .md definition files with frontmatter, APKG generates a summary file that includes:

  • The resolved system prompt (from agent.systemPrompt in apkg.json — inline or read from file)
  • Tool bindings with required/optional status
  • Model preferences

The table below summarizes which features work across the three documented tools:

FeatureClaude CodeCursorCodex
Native agent supportYesYesYes
File formatMarkdownMarkdownTOML
nameYesYesYes
descriptionYesYesYes
toolsYesYesNo (uses sandbox_mode)
modelYesPartialYes
System prompt / instructionsMarkdown bodyMarkdown bodydeveloper_instructions
Auto-delegation from descriptionYesYesNo (explicit request only)
@-mention invocationYes (@"agent (agent)")YesNo
hooksYesNo (ignored)No
mcpServersYesNo (ignored)Yes (mcp_servers)
memoryYesNo (ignored)No
permissionModeYesNo (ignored)No (uses sandbox_mode)
isolationYesNo (ignored)No
backgroundYesNo (ignored)No
Subfolder supportYesYesNot documented
Reads .claude/agents/YesYesNo
Reads .cursor/agents/NoYesNo
Reads .codex/agents/NoYesYes

Because Codex uses TOML instead of Markdown, agent packages cannot use a single file across all three tools. APKG handles this by generating the appropriate format per tool — Markdown for Claude Code and Cursor, TOML for Codex.

When writing agent packages intended for Claude Code and Cursor, stick to the common Markdown subset: name, description, tools, and the system prompt body. Claude Code-specific fields like hooks and memory are safely ignored by Cursor.

Windsurf and Kiro have varying levels of agent support. As their agent systems are less extensively documented, details will be added as they are verified. For now:

  • Windsurf — Agents are mapped to Windsurf’s rule system. The system prompt becomes rule content.
  • Kiro — Kiro has partial agent support through its steering rules.
PageDescription
Agent package typeManifest fields, tool bindings, and system prompt resolution
Tool Setup ExplainedDetection, precedence, and the generic setup mechanism
Create an agent packageStep-by-step authoring guide