Skip to content
Docs

Agent System

The agent system is CodeForge’s flagship plugin. It gives you access to 21 specialized AI agents, each purpose-built for a specific kind of development task — from architecture planning and code exploration to test writing and security auditing. When you make a request, the system automatically delegates to the most appropriate agent, so you get expert-level results without having to think about which tool to use.

When you ask Claude to do something, the agent system analyzes your request and routes it to the specialist best suited for the job. Each agent carries its own system prompt, tool restrictions, permission mode, and domain expertise. This means an architecture question goes to an agent that thinks in terms of system design, while a “write tests for this” request goes to an agent that knows testing frameworks inside and out.

Delegation happens transparently. You just describe what you need, and the right agent picks it up. Here are some examples:

  • “Plan the implementation for user notifications” routes to the architect agent, which explores the codebase, identifies patterns, and produces a structured plan — without modifying any files
  • “Find all API endpoint definitions” routes to the explorer agent, which uses Glob, Grep, and ast-grep to efficiently discover and map code
  • “Write tests for the auth module” routes to the test-writer agent, which detects your test framework, studies existing conventions, writes comprehensive tests, and verifies they pass
  • “Refactor this function to reduce complexity” routes to the refactorer agent, which works in a git worktree and runs regression checks after every edit

What Makes Agents Different From Regular Prompts

Section titled “What Makes Agents Different From Regular Prompts”

Each agent is more than just a system prompt. Agents carry:

  • Tool restrictions — read-only agents physically cannot modify files. The explorer, architect, and researcher agents have their write tools removed entirely.
  • Permission modes — some agents run in plan mode (read-only), others in acceptEdits (can write with approval), and the generalist inherits the session’s default.
  • Frontloaded skills — agents come pre-loaded with relevant skills. The architect gets api-design and spec skills. The test-writer gets the testing skill. This domain knowledge is available immediately without manual activation.
  • Custom hooks — agents can register their own hooks. The refactorer runs verify-no-regression.py after every edit. The test-writer runs verify-tests-pass.py at the end of every turn.
  • Isolation — destructive agents like the refactorer and test-writer work in git worktrees, keeping your main branch clean until changes are verified.

One of CodeForge’s most distinctive features is that it completely replaces Claude Code’s built-in agents with enhanced custom specialists. This is not a prompt-level suggestion — it is a hook-level interception that guarantees every agent spawn uses a CodeForge specialist instead of a stock agent.

The redirect-builtin-agents.py script registers as a PreToolUse hook on the Task tool. Every time Claude spawns a subagent, the hook fires before the agent is created:

  1. The hook reads the requested subagent_type from the Task tool input
  2. It checks the type against a redirect map of built-in → custom agent mappings
  3. If the type matches a built-in agent, the hook rewrites the subagent_type to the fully-qualified custom agent name (e.g., Explore becomes agent-system:explorer)
  4. The modified request proceeds, and the custom agent spawns instead of the stock one
  5. All other parameters — the prompt, description, and context — pass through unchanged

The redirect map covers all six of Claude Code’s built-in agent types:

REDIRECT_MAP = {
"Explore": "explorer",
"Plan": "architect",
"general-purpose": "generalist",
"Bash": "bash-exec",
"claude-code-guide": "claude-guide",
"statusline-setup": "statusline-config",
}

Each redirect is a strict improvement. The custom agents carry capabilities that stock agents lack:

  • Frontloaded skills — the architect loads api-design, the explorer loads ast-grep-patterns, the claude-guide loads claude-code-headless and claude-agent-sdk. Stock agents load nothing.
  • Calibrated models — the architect uses Opus for deep reasoning, the explorer uses Haiku for speed. Stock agents all inherit the session default.
  • Safety hooks — read-only agents have guard-readonly-bash.py blocking write operations. The refactorer runs regression checks after every edit. Stock agents have no per-agent safety enforcement.
  • Focused system prompts — each custom agent has a detailed system prompt shaping its behavior, expertise boundaries, and workflow. Stock agents use a generic prompt.
  • Worktree isolation — the test-writer, refactorer, migrator, and doc-writer work in isolated git worktrees. Stock agents always work on the active branch.

The redirect is fully transparent to you and to Claude. Using either name works — Explore and explorer both resolve to the same enhanced agent.

The agent system includes two key safety mechanisms that run automatically.

Every time a subagent starts, the inject-cwd.py hook fires. It reads the current working directory and injects it as context for the agent, ensuring every agent knows exactly which project directory to work in. This prevents agents from accidentally operating in the wrong directory — a subtle but important safeguard when working across multiple projects.

The hook fires on the SubagentStart event and adds a message like: “Working Directory: /workspaces/projects/MyApp — restrict all file operations to this directory.”

Agents marked as read-only (architect, explorer, researcher, and others) are protected by guard-readonly-bash.py. This hook intercepts every Bash command before execution and blocks anything that would modify state.

The guard is thorough. It blocks:

  • File mutationsrm, mv, cp, mkdir, touch, chmod, and dozens more
  • Git writesgit push, git commit, git merge, git reset, and other state-changing git commands
  • Package managerspip install, npm install, cargo install, and similar
  • Redirections — output redirection (>, >>) that would create or overwrite files
  • Bypass attempts — command chaining (&&, ||, ;), piping into interpreters (curl | bash), command substitution ($(rm file)), and path-prefixed commands (/usr/bin/rm)

The guard supports two modes: general-readonly (blocklist approach — blocks known write commands) and git-readonly (allowlist approach — only permits specific safe commands like git log, git diff, git blame, and a curated set of read-only utilities).

CodeForge includes 21 specialized agents. Each one is tailored for a specific class of development task.

These agents investigate, analyze, and report — they never modify files.

AgentRoleModelSkills
architectSystem design, implementation planning, trade-off analysisOpusapi-design, spec skills
explorerFast codebase navigation, file discovery, pattern matchingHaikuast-grep-patterns
researcherDeep investigation, information gathering, web researchSonnetdocumentation-patterns
claude-guideClaude Code usage guidance and best practicesHaikuclaude-code-headless, claude-agent-sdk
debug-logsLog analysis, error diagnosis, debuggingSonnetdebugging
dependency-analystDependency analysis, version conflicts, upgrade pathsHaikudependency-management
git-archaeologistGit history analysis, blame, bisect, forensicsHaikugit-forensics
perf-profilerPerformance profiling, bottleneck identificationSonnetperformance-profiling
security-auditorSecurity audit, vulnerability assessment, OWASP checksSonnetsecurity-checklist
spec-writerSpecification authoring and refinementOpusspecification-writing

These agents can read and write files, run commands, and make changes to your codebase.

AgentRoleModelIsolationSkills
generalistGeneral-purpose development tasksInheritedNospec skills
test-writerTest creation, coverage analysis, framework detectionOpusWorktreetesting
refactorerBehavior-preserving code transformationsOpusWorktreerefactoring-patterns
doc-writerDocumentation writing and maintenanceOpusWorktreedocumentation-patterns
migratorCode migration, framework upgradesOpusWorktreemigration-patterns
bash-execShell command execution and scriptingSonnetNo
statusline-configStatusline customizationSonnetNo

The agent system registers hooks across several lifecycle events:

ScriptEventWhat It Does
redirect-builtin-agents.pyPreToolUse (Task)Redirects built-in agent types to CodeForge’s custom specialists
inject-cwd.pySubagentStartInjects the working directory so agents operate in the correct project
guard-readonly-bash.pyPreToolUse (Bash)Blocks write operations for read-only agents
verify-no-regression.pyPostToolUse (Edit)Checks for test regressions after code edits (refactorer)
verify-tests-pass.pyStopValidates all tests pass at the end of a turn (test-writer)
task-completed-check.pyTaskCompletedVerifies task results meet requirements in team workflows
teammate-idle-check.pyTeammateIdleMonitors teammate activity and reassigns work if needed

Each agent is defined as a Markdown file in the plugin’s agents/ directory. The file’s YAML frontmatter configures the agent’s technical properties, while the Markdown body contains the agent’s system prompt.

Here is a simplified example of what an agent definition looks like:

---
name: architect
description: >-
Read-only software architect agent that designs implementation plans...
tools: Read, Glob, Grep, Bash, WebSearch, WebFetch
model: opus
permissionMode: plan
skills:
- api-design
- spec-new
hooks:
PreToolUse:
- matcher: Bash
type: command
command: "python3 ${CLAUDE_PLUGIN_ROOT}/scripts/guard-readonly-bash.py --mode general-readonly"
---
# Architect Agent
You are a **senior software architect** specializing in implementation planning...

The tools field controls which tools the agent can access. The permissionMode sets the approval level. The hooks section registers agent-specific hooks that only fire for that particular agent. The skills field pre-loads domain knowledge.

The frontmatter also supports several other configuration options:

FieldPurposeExample Values
modelWhich Claude model the agent usesopus, sonnet, haiku, inherit
colorAgent identifier color in the UImagenta, blue, green, yellow
permissionModeTool approval levelplan, acceptEdits, default
isolationWhether the agent works in a git worktreeworktree (or omitted for no isolation)
memoryMemory persistence scopeproject
disallowedToolsTools explicitly blocked for the agentEnterPlanMode, TeamCreate

Every agent follows a standardized project context discovery process before starting work. This ensures agents respect project-specific conventions, tech stack choices, and architectural boundaries:

  1. Read Claude Rules — agents scan .claude/rules/*.md for mandatory constraints like workspace scoping and spec workflow rules
  2. Read CLAUDE.md files — agents walk up the directory tree reading CLAUDE.md files at each level, where more specific files take precedence over general ones
  3. Apply conventions — naming patterns, framework choices, architecture boundaries, and workflow rules discovered in these files override the agent’s defaults

This discovery process is particularly important because it means agents adapt to your project rather than applying generic patterns.

The agent system supports multi-agent team workflows for complex tasks. When a task is too large for a single agent, the system can spawn a team of specialists that work in parallel on different aspects of the problem.

For example, implementing a feature from a specification might involve:

  • A researcher exploring the codebase for patterns and conventions
  • A test-writer creating tests in a worktree
  • A doc-writer updating documentation

The team is coordinated through the task system, with hooks like task-completed-check.py and teammate-idle-check.py ensuring smooth collaboration.

The recommended team compositions vary by task type:

Task TypeRecommended Teammates
Full-stack featureresearcher + test-writer + doc-writer
Backend-heavy workresearcher + test-writer
Security-sensitive featuresecurity-auditor + test-writer
Refactoringrefactorer + test-writer
Multi-service changeresearcher per service + test-writer

See the Spec Workflow plugin for how team spawning integrates with specification-driven development.

  • Agents Reference — detailed per-agent documentation with usage examples
  • Skills Reference — skills that agents leverage for domain expertise
  • Hooks — how hook scripts integrate with the agent lifecycle
  • Skill Engine — the plugin that manages skill auto-suggestion