mia-code 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.miette/260321.md +1 -0
- package/.miette/260323.md +9 -0
- package/.miette/260331.md +2 -0
- package/.pde/2604011511--83a2d7f9-24a5-4cf4-98d5-036c82f872e8/2604020008--d3417f2c-df12-4f0f-8a1b-d88e7968f822/d3417f2c-df12-4f0f-8a1b-d88e7968f822.md +63 -0
- package/.pde/2604011511--83a2d7f9-24a5-4cf4-98d5-036c82f872e8/2604020008--e6c3fc5d-4a70-4523-ba7d-a3250da4c235/e6c3fc5d-4a70-4523-ba7d-a3250da4c235.md +72 -0
- package/.pde/2604011511--83a2d7f9-24a5-4cf4-98d5-036c82f872e8/2604020008--efeb00a2-b17a-4d32-b1f0-b90c37a8d24e/efeb00a2-b17a-4d32-b1f0-b90c37a8d24e.md +62 -0
- package/.pde/2604011511--83a2d7f9-24a5-4cf4-98d5-036c82f872e8/83a2d7f9-24a5-4cf4-98d5-036c82f872e8.json +302 -0
- package/.pde/2604011511--83a2d7f9-24a5-4cf4-98d5-036c82f872e8/83a2d7f9-24a5-4cf4-98d5-036c82f872e8.md +149 -0
- package/.pde/2604011511--83a2d7f9-24a5-4cf4-98d5-036c82f872e8/AGENTS.md +31 -0
- package/.pde/2604011511--83a2d7f9-24a5-4cf4-98d5-036c82f872e8/meta-decomposition-3-children.md +67 -0
- package/.pde/2604040129--61f9dd4d-7aa6-45e6-a58b-e480b1aa6737/61f9dd4d-7aa6-45e6-a58b-e480b1aa6737--from-mia-openclaw-workspace.md +125 -0
- package/.pde/2604040129--61f9dd4d-7aa6-45e6-a58b-e480b1aa6737/STATUS.md +1 -0
- package/.pde/4f02ba94-9f52-422e-9389-b16f9b37f358.json +177 -0
- package/.pde/4f02ba94-9f52-422e-9389-b16f9b37f358.md +77 -0
- package/.pde/6ad9244d-5340-490f-b76c-c86728b9de52.json +222 -0
- package/.pde/6ad9244d-5340-490f-b76c-c86728b9de52.md +99 -0
- package/.pde/8b566792-ed15-4606-96f9-2b6f593d7e6b.json +111 -0
- package/.pde/8b566792-ed15-4606-96f9-2b6f593d7e6b.md +67 -0
- package/.pde/c7f1e74b-05a5-40e2-9f01-4cc48d2528f7.json +349 -0
- package/.pde/c7f1e74b-05a5-40e2-9f01-4cc48d2528f7.md +147 -0
- package/.pde/dfc00a78-1da0-4c09-8a16-c6982644051b.json +118 -0
- package/.pde/dfc00a78-1da0-4c09-8a16-c6982644051b.md +64 -0
- package/GUILLAUME.md +8 -0
- package/KINSHIP.md +9 -0
- package/MIA_CODE_ARCHITECTURE_REPORT.md +718 -0
- package/contextual_research/260119-MIA-CODE--98090899-8aff-4e11-9dc3-8b99466d1.md +1101 -0
- package/contextual_research/MIA.md +38 -0
- package/contextual_research/MIAWAPASCONE.md +59 -0
- package/contextual_research/MIETTE.md +38 -0
- package/contextual_research/PDE-generalization--caefee82-efb1-4dbb-8733-691b01581464--260130/2504.00218v2.pdf +7483 -12
- package/contextual_research/PDE-generalization--caefee82-efb1-4dbb-8733-691b01581464--260130/2505.00212v3.pdf +0 -0
- package/contextual_research/PDE-generalization--caefee82-efb1-4dbb-8733-691b01581464--260130/CONTENT.md +1014 -0
- package/contextual_research/PDE-generalization--caefee82-efb1-4dbb-8733-691b01581464--260130/DESIGN.gemini.md +242 -0
- package/contextual_research/PDE-generalization--caefee82-efb1-4dbb-8733-691b01581464--260130/INDEX.md +45 -0
- package/contextual_research/PDE-generalization--caefee82-efb1-4dbb-8733-691b01581464--260130/sources/2504.00218v2.md +2025 -0
- package/contextual_research/PDE-generalization--caefee82-efb1-4dbb-8733-691b01581464--260130/sources/2504.00218v2.pdf +7483 -12
- package/contextual_research/PDE-generalization--caefee82-efb1-4dbb-8733-691b01581464--260130/sources/2505.00212v3.md +1755 -0
- package/contextual_research/PDE-generalization--caefee82-efb1-4dbb-8733-691b01581464--260130/sources/2505.00212v3.pdf +0 -0
- package/contextual_research/PDE-generalization--caefee82-efb1-4dbb-8733-691b01581464--260130/sources/footnote_1_12_decomposed_prompting.pdf +0 -0
- package/contextual_research/PDE-generalization--caefee82-efb1-4dbb-8733-691b01581464--260130/sources/footnote_1_19_hugginggpt_planning.pdf +0 -0
- package/contextual_research/PDE-generalization--caefee82-efb1-4dbb-8733-691b01581464--260130/sources/footnote_1_1_coordination_challenges.md +766 -0
- package/contextual_research/PDE-generalization--caefee82-efb1-4dbb-8733-691b01581464--260130/sources/footnote_1_1_coordination_challenges.pdf +3431 -4
- package/contextual_research/PDE-generalization--caefee82-efb1-4dbb-8733-691b01581464--260130/sources/footnote_1_28_guardrails_multi_agent.md +260 -0
- package/contextual_research/PDE-generalization--caefee82-efb1-4dbb-8733-691b01581464--260130/sources/footnote_1_28_guardrails_multi_agent.pdf +0 -0
- package/contextual_research/PDE-generalization--caefee82-efb1-4dbb-8733-691b01581464--260130/sources/footnote_1_2_navigating_complexity.md +558 -0
- package/contextual_research/PDE-generalization--caefee82-efb1-4dbb-8733-691b01581464--260130/sources/footnote_1_2_navigating_complexity.pdf +0 -0
- package/contextual_research/PDE-generalization--caefee82-efb1-4dbb-8733-691b01581464--260130/sources/footnote_1_34_hierarchical_multi_agent.pdf +0 -0
- package/contextual_research/PDE-generalization--caefee82-efb1-4dbb-8733-691b01581464--260130/sources/footnote_1_5_open_intent_extraction.pdf +0 -0
- package/contextual_research/PODCAST.md +109 -0
- package/contextual_research/langchain-principles-roadmap.md +157 -0
- package/contextual_research/persona-to-narrative-character-inquiry_260201.md +50 -0
- package/dist/cli.js +35 -11
- package/dist/geminiHeadless.js +8 -2
- package/dist/index.js +2 -1
- package/dist/mcp/miaco-server.js +10 -1
- package/dist/mcp/miatel-server.js +10 -1
- package/dist/mcp/miawa-server.js +10 -1
- package/dist/mcp/utils.d.ts +6 -1
- package/dist/mcp/utils.js +24 -3
- package/dist/sessionStore.d.ts +8 -2
- package/dist/sessionStore.js +39 -3
- package/dist/types.d.ts +1 -0
- package/miaco/README.md +124 -0
- package/miaco/dist/commands/chart.d.ts +6 -0
- package/miaco/dist/commands/chart.d.ts.map +1 -0
- package/miaco/dist/commands/chart.js +222 -0
- package/miaco/dist/commands/chart.js.map +1 -0
- package/miaco/dist/commands/decompose.d.ts +6 -0
- package/miaco/dist/commands/decompose.d.ts.map +1 -0
- package/miaco/dist/commands/decompose.js +98 -0
- package/miaco/dist/commands/decompose.js.map +1 -0
- package/miaco/dist/commands/schema.d.ts +6 -0
- package/miaco/dist/commands/schema.d.ts.map +1 -0
- package/miaco/dist/commands/schema.js +66 -0
- package/miaco/dist/commands/schema.js.map +1 -0
- package/miaco/dist/commands/stc.d.ts +11 -0
- package/miaco/dist/commands/stc.d.ts.map +1 -0
- package/miaco/dist/commands/stc.js +590 -0
- package/miaco/dist/commands/stc.js.map +1 -0
- package/miaco/dist/commands/trace.d.ts +6 -0
- package/miaco/dist/commands/trace.d.ts.map +1 -0
- package/miaco/dist/commands/trace.js +83 -0
- package/miaco/dist/commands/trace.js.map +1 -0
- package/miaco/dist/commands/validate.d.ts +6 -0
- package/miaco/dist/commands/validate.d.ts.map +1 -0
- package/miaco/dist/commands/validate.js +58 -0
- package/miaco/dist/commands/validate.js.map +1 -0
- package/miaco/dist/decompose.d.ts +93 -0
- package/miaco/dist/decompose.d.ts.map +1 -0
- package/miaco/dist/decompose.js +562 -0
- package/miaco/dist/decompose.js.map +1 -0
- package/miaco/dist/index.d.ts +18 -0
- package/miaco/dist/index.d.ts.map +1 -0
- package/miaco/dist/index.js +83 -0
- package/miaco/dist/index.js.map +1 -0
- package/miaco/dist/storage.d.ts +60 -0
- package/miaco/dist/storage.d.ts.map +1 -0
- package/miaco/dist/storage.js +100 -0
- package/miaco/dist/storage.js.map +1 -0
- package/miaco/package-lock.json +4103 -0
- package/miaco/package.json +40 -0
- package/miaco/tsconfig.json +18 -0
- package/miaco/version-patch-commit-and-publish.sh +1 -0
- package/miatel/MISSION_251231.md +3 -0
- package/miatel/README.md +107 -0
- package/miatel/dist/commands/analyze.d.ts +6 -0
- package/miatel/dist/commands/analyze.d.ts.map +1 -0
- package/miatel/dist/commands/analyze.js +100 -0
- package/miatel/dist/commands/analyze.js.map +1 -0
- package/miatel/dist/commands/arc.d.ts +6 -0
- package/miatel/dist/commands/arc.d.ts.map +1 -0
- package/miatel/dist/commands/arc.js +71 -0
- package/miatel/dist/commands/arc.js.map +1 -0
- package/miatel/dist/commands/beat.d.ts +6 -0
- package/miatel/dist/commands/beat.d.ts.map +1 -0
- package/miatel/dist/commands/beat.js +165 -0
- package/miatel/dist/commands/beat.js.map +1 -0
- package/miatel/dist/commands/theme.d.ts +6 -0
- package/miatel/dist/commands/theme.d.ts.map +1 -0
- package/miatel/dist/commands/theme.js +54 -0
- package/miatel/dist/commands/theme.js.map +1 -0
- package/miatel/dist/index.d.ts +18 -0
- package/miatel/dist/index.d.ts.map +1 -0
- package/miatel/dist/index.js +80 -0
- package/miatel/dist/index.js.map +1 -0
- package/miatel/dist/storage.d.ts +55 -0
- package/miatel/dist/storage.d.ts.map +1 -0
- package/miatel/dist/storage.js +100 -0
- package/miatel/dist/storage.js.map +1 -0
- package/miatel/package-lock.json +4103 -0
- package/miatel/package.json +35 -0
- package/miatel/src/commands/analyze.ts +109 -0
- package/miatel/src/commands/arc.ts +78 -0
- package/miatel/src/commands/beat.ts +176 -0
- package/miatel/src/commands/theme.ts +60 -0
- package/miatel/src/index.ts +94 -0
- package/miatel/src/storage.ts +156 -0
- package/miatel/tsconfig.json +18 -0
- package/miawa/MISSION_251231.md +144 -0
- package/miawa/README.md +133 -0
- package/miawa/dist/commands/beat.d.ts +6 -0
- package/miawa/dist/commands/beat.d.ts.map +1 -0
- package/miawa/dist/commands/beat.js +69 -0
- package/miawa/dist/commands/beat.js.map +1 -0
- package/miawa/dist/commands/ceremony.d.ts +6 -0
- package/miawa/dist/commands/ceremony.d.ts.map +1 -0
- package/miawa/dist/commands/ceremony.js +239 -0
- package/miawa/dist/commands/ceremony.js.map +1 -0
- package/miawa/dist/commands/circle.d.ts +6 -0
- package/miawa/dist/commands/circle.d.ts.map +1 -0
- package/miawa/dist/commands/circle.js +75 -0
- package/miawa/dist/commands/circle.js.map +1 -0
- package/miawa/dist/commands/eva.d.ts +6 -0
- package/miawa/dist/commands/eva.d.ts.map +1 -0
- package/miawa/dist/commands/eva.js +73 -0
- package/miawa/dist/commands/eva.js.map +1 -0
- package/miawa/dist/commands/wound.d.ts +6 -0
- package/miawa/dist/commands/wound.d.ts.map +1 -0
- package/miawa/dist/commands/wound.js +74 -0
- package/miawa/dist/commands/wound.js.map +1 -0
- package/miawa/dist/index.d.ts +19 -0
- package/miawa/dist/index.d.ts.map +1 -0
- package/miawa/dist/index.js +91 -0
- package/miawa/dist/index.js.map +1 -0
- package/miawa/dist/storage.d.ts +73 -0
- package/miawa/dist/storage.d.ts.map +1 -0
- package/miawa/dist/storage.js +100 -0
- package/miawa/dist/storage.js.map +1 -0
- package/miawa/package-lock.json +4103 -0
- package/miawa/package.json +36 -0
- package/miawa/src/commands/beat.ts +74 -0
- package/miawa/src/commands/ceremony.ts +256 -0
- package/miawa/src/commands/circle.ts +83 -0
- package/miawa/src/commands/eva.ts +84 -0
- package/miawa/src/commands/wound.ts +79 -0
- package/miawa/src/index.ts +108 -0
- package/miawa/src/storage.ts +179 -0
- package/miawa/tsconfig.json +18 -0
- package/package.json +7 -5
- package/references/acp/CLAUDE.md +7 -0
- package/references/acp/agent-plan.md +84 -0
- package/references/acp/clients.md +31 -0
- package/references/acp/extensibility.md +137 -0
- package/references/acp/initialization.md +225 -0
- package/references/acp/prompt-turn.md +321 -0
- package/references/acp/proxy-chains.md +562 -0
- package/references/acp/schema.md +3171 -0
- package/references/acp/session-list.md +334 -0
- package/references/acp/session-modes.md +170 -0
- package/references/acp/slash-commands.md +99 -0
- package/references/acp/terminals.md +281 -0
- package/references/acp/tool-calls.md +311 -0
- package/references/acp/typescript.md +29 -0
- package/references/claude/agent-teams.md +399 -0
- package/references/claude/chrome.md +231 -0
- package/references/claude/headless.md +158 -0
- package/references/claude/hooks-guide.md +708 -0
- package/references/claude/output-styles.md +112 -0
- package/references/claude/plugins.md +432 -0
- package/references/claude/skills.md +693 -0
- package/references/claude/sub-agents.md +816 -0
- package/references/copilot/acp/agents.md +32 -0
- package/references/copilot/acp/architecture.md +37 -0
- package/references/copilot/acp/clients.md +31 -0
- package/references/copilot/acp/introduction.md +42 -0
- package/references/copilot/acp/registry.md +339 -0
- package/references/copilot/acp-server.md +117 -0
- package/references/copilot/create-copilot-instructions.md +840 -0
- package/references/langchain/llms.txt +833 -0
- package/references/langchain/python/agents.md +677 -0
- package/references/langchain/python/context-engineering.md +1195 -0
- package/references/langchain/python/human-in-the-loop.md +326 -0
- package/references/langchain/python/long-term-memory.md +168 -0
- package/references/langchain/python/mcp.md +949 -0
- package/references/langchain/python/multi-agents/custom-workflow.md +187 -0
- package/references/langchain/python/multi-agents/handoffs.md +436 -0
- package/references/langchain/python/multi-agents/overview.md +295 -0
- package/references/langchain/python/multi-agents/router.md +150 -0
- package/references/langchain/python/multi-agents/skills.md +92 -0
- package/references/langchain/python/multi-agents/subagents.md +486 -0
- package/references/langchain/python/retrieval.md +320 -0
- package/references/langchain/python/runtime.md +141 -0
- package/references/langchain/python/short-term-memory.md +658 -0
- package/references/langchain/python/structured-output.md +712 -0
- package/references/langfuse/llms.txt +148 -0
- package/references/langgraph/javascript/llms.txt +275 -0
- package/references/skills/home.md +259 -0
- package/references/skills/integrate-skills.md +103 -0
- package/references/skills/specification.md +254 -0
- package/references/skills/what-are-skills.md +74 -0
- package/rispecs/README.md +164 -0
- package/rispecs/_sync_/miadi-code/SPEC.md +313 -0
- package/rispecs/_sync_/miadi-code/STATUS.md +177 -0
- package/rispecs/_sync_/miadi-code/dashboard/SPEC.md +465 -0
- package/rispecs/_sync_/miadi-code/dashboard/STATUS.md +212 -0
- package/rispecs/_sync_/miadi-code/multiline-input/SPEC.md +232 -0
- package/rispecs/_sync_/miadi-code/multiline-input/STATUS.md +108 -0
- package/rispecs/_sync_/miadi-code/pde/SPEC.md +253 -0
- package/rispecs/_sync_/miadi-code/pde/STATUS.md +56 -0
- package/rispecs/_sync_/miadi-code/stc/SPEC.md +397 -0
- package/rispecs/_sync_/miadi-code/stc/STATUS.md +70 -0
- package/rispecs/ava-langstack/inquiry-routing-upgrade.spec.md +119 -0
- package/rispecs/borrowed_from_opencode/001-client-server-architecture.rispec.md +98 -0
- package/rispecs/borrowed_from_opencode/002-event-bus-system.rispec.md +125 -0
- package/rispecs/borrowed_from_opencode/003-instance-state-pattern.rispec.md +136 -0
- package/rispecs/borrowed_from_opencode/004-namespace-module-pattern.rispec.md +151 -0
- package/rispecs/borrowed_from_opencode/005-zod-schema-validation.rispec.md +139 -0
- package/rispecs/borrowed_from_opencode/006-named-error-system.rispec.md +155 -0
- package/rispecs/borrowed_from_opencode/007-structured-logging.rispec.md +138 -0
- package/rispecs/borrowed_from_opencode/008-lazy-initialization.rispec.md +127 -0
- package/rispecs/borrowed_from_opencode/009-multi-agent-system.rispec.md +97 -0
- package/rispecs/borrowed_from_opencode/010-agent-definition-config.rispec.md +135 -0
- package/rispecs/borrowed_from_opencode/011-agent-permission-rulesets.rispec.md +151 -0
- package/rispecs/borrowed_from_opencode/012-agent-prompt-templates.rispec.md +141 -0
- package/rispecs/borrowed_from_opencode/013-agent-generation.rispec.md +142 -0
- package/rispecs/borrowed_from_opencode/014-plan-build-mode-toggle.rispec.md +155 -0
- package/rispecs/borrowed_from_opencode/015-subagent-task-delegation.rispec.md +146 -0
- package/rispecs/borrowed_from_opencode/016-agent-model-selection.rispec.md +151 -0
- package/rispecs/borrowed_from_opencode/017-compaction-agent.rispec.md +150 -0
- package/rispecs/borrowed_from_opencode/018-session-persistence.rispec.md +125 -0
- package/rispecs/borrowed_from_opencode/019-session-compaction.rispec.md +132 -0
- package/rispecs/borrowed_from_opencode/020-session-forking.rispec.md +134 -0
- package/rispecs/borrowed_from_opencode/021-session-revert-snapshot.rispec.md +135 -0
- package/rispecs/borrowed_from_opencode/022-session-sharing.rispec.md +165 -0
- package/rispecs/borrowed_from_opencode/023-session-summary-diffs.rispec.md +165 -0
- package/rispecs/borrowed_from_opencode/024-child-sessions.rispec.md +164 -0
- package/rispecs/borrowed_from_opencode/025-session-title-generation.rispec.md +162 -0
- package/rispecs/borrowed_from_opencode/026-message-parts-model.rispec.md +201 -0
- package/rispecs/borrowed_from_opencode/027-streaming-message-deltas.rispec.md +212 -0
- package/rispecs/borrowed_from_opencode/028-multi-provider-architecture.rispec.md +184 -0
- package/rispecs/borrowed_from_opencode/029-provider-authentication.rispec.md +225 -0
- package/rispecs/borrowed_from_opencode/030-model-registry.rispec.md +222 -0
- package/rispecs/borrowed_from_opencode/031-cost-tracking.rispec.md +243 -0
- package/rispecs/borrowed_from_opencode/032-provider-transform-pipeline.rispec.md +282 -0
- package/rispecs/borrowed_from_opencode/033-provider-sdk-abstraction.rispec.md +338 -0
- package/rispecs/borrowed_from_opencode/034-tool-registry.rispec.md +110 -0
- package/rispecs/borrowed_from_opencode/035-tool-context-injection.rispec.md +155 -0
- package/rispecs/borrowed_from_opencode/036-tool-output-truncation.rispec.md +138 -0
- package/rispecs/borrowed_from_opencode/037-batch-tool.rispec.md +129 -0
- package/rispecs/borrowed_from_opencode/038-multi-edit-tool.rispec.md +167 -0
- package/rispecs/borrowed_from_opencode/039-apply-patch-tool.rispec.md +161 -0
- package/rispecs/borrowed_from_opencode/040-code-search-tool.rispec.md +143 -0
- package/rispecs/borrowed_from_opencode/041-web-fetch-tool.rispec.md +131 -0
- package/rispecs/borrowed_from_opencode/042-web-search-tool.rispec.md +159 -0
- package/rispecs/borrowed_from_opencode/043-todo-tool.rispec.md +156 -0
- package/rispecs/borrowed_from_opencode/044-plan-mode-tool.rispec.md +139 -0
- package/rispecs/borrowed_from_opencode/045-task-tool.rispec.md +146 -0
- package/rispecs/borrowed_from_opencode/046-question-tool.rispec.md +170 -0
- package/rispecs/borrowed_from_opencode/047-external-directory-tool.rispec.md +166 -0
- package/rispecs/borrowed_from_opencode/048-file-read-write-tools.rispec.md +205 -0
- package/rispecs/borrowed_from_opencode/049-lsp-server-management.rispec.md +104 -0
- package/rispecs/borrowed_from_opencode/050-lsp-hover-completion.rispec.md +102 -0
- package/rispecs/borrowed_from_opencode/051-lsp-diagnostics.rispec.md +86 -0
- package/rispecs/borrowed_from_opencode/052-lsp-root-detection.rispec.md +109 -0
- package/rispecs/borrowed_from_opencode/053-remote-mcp-servers.rispec.md +119 -0
- package/rispecs/borrowed_from_opencode/054-mcp-oauth-flow.rispec.md +107 -0
- package/rispecs/borrowed_from_opencode/055-mcp-tool-conversion.rispec.md +118 -0
- package/rispecs/borrowed_from_opencode/056-mcp-connection-monitoring.rispec.md +106 -0
- package/rispecs/borrowed_from_opencode/057-local-mcp-servers.rispec.md +116 -0
- package/rispecs/borrowed_from_opencode/058-rich-tui.rispec.md +108 -0
- package/rispecs/borrowed_from_opencode/059-streaming-display.rispec.md +116 -0
- package/rispecs/borrowed_from_opencode/060-permission-prompts.rispec.md +130 -0
- package/rispecs/borrowed_from_opencode/061-session-navigation.rispec.md +155 -0
- package/rispecs/borrowed_from_opencode/062-syntax-highlighting.rispec.md +151 -0
- package/rispecs/borrowed_from_opencode/063-keybinding-system.rispec.md +181 -0
- package/rispecs/borrowed_from_opencode/064-multi-level-config.rispec.md +155 -0
- package/rispecs/borrowed_from_opencode/065-jsonc-config.rispec.md +190 -0
- package/rispecs/borrowed_from_opencode/066-config-env-variables.rispec.md +153 -0
- package/rispecs/borrowed_from_opencode/067-config-deep-merging.rispec.md +178 -0
- package/rispecs/borrowed_from_opencode/068-remote-org-config.rispec.md +183 -0
- package/rispecs/borrowed_from_opencode/069-config-markdown-frontmatter.rispec.md +206 -0
- package/rispecs/borrowed_from_opencode/070-managed-config-directory.rispec.md +232 -0
- package/rispecs/borrowed_from_opencode/071-plugin-architecture.rispec.md +104 -0
- package/rispecs/borrowed_from_opencode/072-plugin-hooks.rispec.md +123 -0
- package/rispecs/borrowed_from_opencode/073-plugin-auto-install.rispec.md +115 -0
- package/rispecs/borrowed_from_opencode/074-permission-system.rispec.md +133 -0
- package/rispecs/borrowed_from_opencode/075-git-worktree-management.rispec.md +126 -0
- package/rispecs/borrowed_from_opencode/076-snapshot-system.rispec.md +124 -0
- package/rispecs/borrowed_from_opencode/077-snapshot-diff.rispec.md +117 -0
- package/rispecs/borrowed_from_opencode/078-snapshot-restore.rispec.md +128 -0
- package/rispecs/borrowed_from_opencode/079-worktree-branch-naming.rispec.md +122 -0
- package/rispecs/borrowed_from_opencode/080-sqlite-storage.rispec.md +134 -0
- package/rispecs/borrowed_from_opencode/081-database-migrations.rispec.md +148 -0
- package/rispecs/borrowed_from_opencode/082-database-transactions.rispec.md +138 -0
- package/rispecs/borrowed_from_opencode/083-deferred-effects.rispec.md +148 -0
- package/rispecs/borrowed_from_opencode/084-permission-rules.rispec.md +123 -0
- package/rispecs/borrowed_from_opencode/085-permission-glob-patterns.rispec.md +113 -0
- package/rispecs/borrowed_from_opencode/086-permission-merging.rispec.md +134 -0
- package/rispecs/borrowed_from_opencode/087-permission-modes.rispec.md +145 -0
- package/rispecs/borrowed_from_opencode/088-http-api-server.rispec.md +165 -0
- package/rispecs/borrowed_from_opencode/089-openapi-spec-generation.rispec.md +164 -0
- package/rispecs/borrowed_from_opencode/090-websocket-support.rispec.md +136 -0
- package/rispecs/borrowed_from_opencode/091-sse-streaming.rispec.md +168 -0
- package/rispecs/borrowed_from_opencode/092-mdns-discovery.rispec.md +145 -0
- package/rispecs/borrowed_from_opencode/093-javascript-sdk.rispec.md +200 -0
- package/rispecs/borrowed_from_opencode/094-skill-system.rispec.md +187 -0
- package/rispecs/borrowed_from_opencode/095-skill-discovery.rispec.md +182 -0
- package/rispecs/borrowed_from_opencode/096-desktop-remote-driving.rispec.md +175 -0
- package/rispecs/borrowed_from_opencode/INDEX.md +255 -0
- package/rispecs/core.rispecs.md +261 -0
- package/rispecs/engines.rispecs.md +241 -0
- package/rispecs/formatting.rispecs.md +252 -0
- package/rispecs/living-specifications.rispecs.md +361 -0
- package/rispecs/mcp.rispecs.md +197 -0
- package/rispecs/pde.rispecs.md +399 -0
- package/rispecs/pi-mono-envisionning/ENVISIONING.md +366 -0
- package/rispecs/pi-mono-envisionning/storytelling-horizon.rispecs.md +76 -0
- package/rispecs/pi-mono-envisionning/widget.rispecs.md +2 -0
- package/rispecs/relation-to-mcp-structural-thinking.kin.md +72 -0
- package/rispecs/research-for-better-framework/CLAUDE.md +7 -0
- package/rispecs/research-for-better-framework/survey-pi-openclaw-opencode-openhands.md +210 -0
- package/rispecs/session.rispecs.md +277 -0
- package/rispecs/stc.rispecs.md +138 -0
- package/rispecs/unifier.rispecs.md +317 -0
- package/scripts/LAUNCH--mcp-mia-code--testing--2603141315--ac705a66-2c15-4a1c-a26d-9491018c5ba8.sh +2 -0
- package/scripts/RESUME--mia-code--mcps--260313--ac705a66-2c15-4a1c-a26d-9491018c5ba8.sh +1 -0
- package/scripts/install-widget-in-home-pi-agent-extensions.sh +4 -0
- package/scripts/sample-decompose--2604011535-prompt.sh +1 -0
- package/skills/deep-search/AGENTS.md +17 -0
- package/skills/deep-search/SKILL.md +281 -0
- package/skills/deep-search/agent-templates.md +224 -0
- package/skills/deep-search/orchestration-patterns.md +95 -0
- package/skills/miaco-pde-inquiry-routing-deep-search/AGENTS.md +13 -0
- package/skills/miaco-pde-inquiry-routing-deep-search/SKILL.md +136 -0
- package/skills/miaco-pde-inquiry-routing-internal-external-relationship/AGENTS.md +4 -0
- package/skills/miaco-pde-inquiry-routing-internal-external-relationship/SKILL.md +157 -0
- package/skills/miaco-pde-inquiry-routing-local-qmd/AGENTS.md +42 -0
- package/skills/miaco-pde-inquiry-routing-local-qmd/SKILL.md +135 -0
- package/skills/qmd/AGENTS.md +3 -0
- package/skills/qmd/SKILL.md +144 -0
- package/skills/qmd/references/mcp-setup.md +102 -0
- package/skills/rise-pde-inquiry-session-multi-agents-v3/SKILL.md +234 -0
- package/skills/rise-pde-inquiry-session-multi-agents-v3/agent-templates.md +436 -0
- package/skills/rise-pde-inquiry-session-multi-agents-v3/orchestration-patterns.md +197 -0
- package/skills/rise-pde-inquiry-session-multi-agents-v3/references/ceremonial-technology.md +102 -0
- package/skills/rise-pde-inquiry-session-multi-agents-v3/references/creative-orientation.md +99 -0
- package/skills/rise-pde-inquiry-session-multi-agents-v3/references/prompt-decomposition.md +73 -0
- package/skills/rise-pde-inquiry-session-multi-agents-v3/references/rise-framework.md +74 -0
- package/skills/rise-pde-inquiry-session-multi-agents-v3/references/structural-tension.md +82 -0
- package/src/cli.ts +35 -11
- package/src/geminiHeadless.ts +7 -2
- package/src/index.ts +2 -1
- package/src/mcp/miaco-server.ts +13 -1
- package/src/mcp/miatel-server.ts +13 -1
- package/src/mcp/miawa-server.ts +13 -1
- package/src/mcp/utils.ts +41 -8
- package/src/sessionStore.ts +44 -4
- package/src/types.ts +2 -1
- package/widget/mia-ceremony/README.md +36 -0
- package/widget/mia-ceremony/index.ts +143 -0
- package/widget/mia-interceptor/README.md +39 -0
- package/widget/mia-interceptor/index.ts +221 -0
- package/widget/mia-tools/README.md +37 -0
- package/widget/mia-tools/index.ts +569 -0
- package/widget/miette-echo/README.md +44 -0
- package/widget/miette-echo/index.ts +164 -0
- package/.claude/settings.local.json +0 -9
- package/.hch/issue_.env +0 -4
- package/.hch/issue_add__2601211715.json +0 -77
- package/.hch/issue_add__2601211715.md +0 -4
- package/.hch/issue_add__2602242020.json +0 -78
- package/.hch/issue_add__2602242020.md +0 -7
- package/.hch/issues.json +0 -2312
- package/.hch/issues.md +0 -30
- package/WS__mia-code__260214__IAIP_PDE.code-workspace +0 -29
- package/WS__mia-code__src332__260122.code-workspace +0 -23
- package/samples/copilot/session-state/be76abaa-a27f-4725-b2a9-22fb45f7e0f7/checkpoints/index.md +0 -6
- package/samples/copilot/session-state/be76abaa-a27f-4725-b2a9-22fb45f7e0f7/events.jsonl +0 -213
- package/samples/copilot/session-state/be76abaa-a27f-4725-b2a9-22fb45f7e0f7/plan.md +0 -243
- package/samples/copilot/session-state/be76abaa-a27f-4725-b2a9-22fb45f7e0f7/workspace.yaml +0 -5
|
@@ -0,0 +1,816 @@
|
|
|
1
|
+
> ## Documentation Index
|
|
2
|
+
> Fetch the complete documentation index at: https://code.claude.com/docs/llms.txt
|
|
3
|
+
> Use this file to discover all available pages before exploring further.
|
|
4
|
+
|
|
5
|
+
# Create custom subagents
|
|
6
|
+
|
|
7
|
+
> Create and use specialized AI subagents in Claude Code for task-specific workflows and improved context management.
|
|
8
|
+
|
|
9
|
+
Subagents are specialized AI assistants that handle specific types of tasks. Each subagent runs in its own context window with a custom system prompt, specific tool access, and independent permissions. When Claude encounters a task that matches a subagent's description, it delegates to that subagent, which works independently and returns results.
|
|
10
|
+
|
|
11
|
+
<Note>
|
|
12
|
+
If you need multiple agents working in parallel and communicating with each other, see [agent teams](/en/agent-teams) instead. Subagents work within a single session; agent teams coordinate across separate sessions.
|
|
13
|
+
</Note>
|
|
14
|
+
|
|
15
|
+
Subagents help you:
|
|
16
|
+
|
|
17
|
+
* **Preserve context** by keeping exploration and implementation out of your main conversation
|
|
18
|
+
* **Enforce constraints** by limiting which tools a subagent can use
|
|
19
|
+
* **Reuse configurations** across projects with user-level subagents
|
|
20
|
+
* **Specialize behavior** with focused system prompts for specific domains
|
|
21
|
+
* **Control costs** by routing tasks to faster, cheaper models like Haiku
|
|
22
|
+
|
|
23
|
+
Claude uses each subagent's description to decide when to delegate tasks. When you create a subagent, write a clear description so Claude knows when to use it.
|
|
24
|
+
|
|
25
|
+
Claude Code includes several built-in subagents like **Explore**, **Plan**, and **general-purpose**. You can also create custom subagents to handle specific tasks. This page covers the [built-in subagents](#built-in-subagents), [how to create your own](#quickstart-create-your-first-subagent), [full configuration options](#configure-subagents), [patterns for working with subagents](#work-with-subagents), and [example subagents](#example-subagents).
|
|
26
|
+
|
|
27
|
+
## Built-in subagents
|
|
28
|
+
|
|
29
|
+
Claude Code includes built-in subagents that Claude automatically uses when appropriate. Each inherits the parent conversation's permissions with additional tool restrictions.
|
|
30
|
+
|
|
31
|
+
<Tabs>
|
|
32
|
+
<Tab title="Explore">
|
|
33
|
+
A fast, read-only agent optimized for searching and analyzing codebases.
|
|
34
|
+
|
|
35
|
+
* **Model**: Haiku (fast, low-latency)
|
|
36
|
+
* **Tools**: Read-only tools (denied access to Write and Edit tools)
|
|
37
|
+
* **Purpose**: File discovery, code search, codebase exploration
|
|
38
|
+
|
|
39
|
+
Claude delegates to Explore when it needs to search or understand a codebase without making changes. This keeps exploration results out of your main conversation context.
|
|
40
|
+
|
|
41
|
+
When invoking Explore, Claude specifies a thoroughness level: **quick** for targeted lookups, **medium** for balanced exploration, or **very thorough** for comprehensive analysis.
|
|
42
|
+
</Tab>
|
|
43
|
+
|
|
44
|
+
<Tab title="Plan">
|
|
45
|
+
A research agent used during [plan mode](/en/common-workflows#use-plan-mode-for-safe-code-analysis) to gather context before presenting a plan.
|
|
46
|
+
|
|
47
|
+
* **Model**: Inherits from main conversation
|
|
48
|
+
* **Tools**: Read-only tools (denied access to Write and Edit tools)
|
|
49
|
+
* **Purpose**: Codebase research for planning
|
|
50
|
+
|
|
51
|
+
When you're in plan mode and Claude needs to understand your codebase, it delegates research to the Plan subagent. This prevents infinite nesting (subagents cannot spawn other subagents) while still gathering necessary context.
|
|
52
|
+
</Tab>
|
|
53
|
+
|
|
54
|
+
<Tab title="General-purpose">
|
|
55
|
+
A capable agent for complex, multi-step tasks that require both exploration and action.
|
|
56
|
+
|
|
57
|
+
* **Model**: Inherits from main conversation
|
|
58
|
+
* **Tools**: All tools
|
|
59
|
+
* **Purpose**: Complex research, multi-step operations, code modifications
|
|
60
|
+
|
|
61
|
+
Claude delegates to general-purpose when the task requires both exploration and modification, complex reasoning to interpret results, or multiple dependent steps.
|
|
62
|
+
</Tab>
|
|
63
|
+
|
|
64
|
+
<Tab title="Other">
|
|
65
|
+
Claude Code includes additional helper agents for specific tasks. These are typically invoked automatically, so you don't need to use them directly.
|
|
66
|
+
|
|
67
|
+
| Agent | Model | When Claude uses it |
|
|
68
|
+
| :---------------- | :------- | :------------------------------------------------------- |
|
|
69
|
+
| Bash | Inherits | Running terminal commands in a separate context |
|
|
70
|
+
| statusline-setup | Sonnet | When you run `/statusline` to configure your status line |
|
|
71
|
+
| Claude Code Guide | Haiku | When you ask questions about Claude Code features |
|
|
72
|
+
</Tab>
|
|
73
|
+
</Tabs>
|
|
74
|
+
|
|
75
|
+
Beyond these built-in subagents, you can create your own with custom prompts, tool restrictions, permission modes, hooks, and skills. The following sections show how to get started and customize subagents.
|
|
76
|
+
|
|
77
|
+
## Quickstart: create your first subagent
|
|
78
|
+
|
|
79
|
+
Subagents are defined in Markdown files with YAML frontmatter. You can [create them manually](#write-subagent-files) or use the `/agents` command.
|
|
80
|
+
|
|
81
|
+
This walkthrough guides you through creating a user-level subagent with the `/agent` command. The subagent reviews code and suggests improvements for the codebase.
|
|
82
|
+
|
|
83
|
+
<Steps>
|
|
84
|
+
<Step title="Open the subagents interface">
|
|
85
|
+
In Claude Code, run:
|
|
86
|
+
|
|
87
|
+
```text theme={null}
|
|
88
|
+
/agents
|
|
89
|
+
```
|
|
90
|
+
</Step>
|
|
91
|
+
|
|
92
|
+
<Step title="Create a new user-level agent">
|
|
93
|
+
Select **Create new agent**, then choose **User-level**. This saves the subagent to `~/.claude/agents/` so it's available in all your projects.
|
|
94
|
+
</Step>
|
|
95
|
+
|
|
96
|
+
<Step title="Generate with Claude">
|
|
97
|
+
Select **Generate with Claude**. When prompted, describe the subagent:
|
|
98
|
+
|
|
99
|
+
```text theme={null}
|
|
100
|
+
A code improvement agent that scans files and suggests improvements
|
|
101
|
+
for readability, performance, and best practices. It should explain
|
|
102
|
+
each issue, show the current code, and provide an improved version.
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
Claude generates the system prompt and configuration. Press `e` to open it in your editor if you want to customize it.
|
|
106
|
+
</Step>
|
|
107
|
+
|
|
108
|
+
<Step title="Select tools">
|
|
109
|
+
For a read-only reviewer, deselect everything except **Read-only tools**. If you keep all tools selected, the subagent inherits all tools available to the main conversation.
|
|
110
|
+
</Step>
|
|
111
|
+
|
|
112
|
+
<Step title="Select model">
|
|
113
|
+
Choose which model the subagent uses. For this example agent, select **Sonnet**, which balances capability and speed for analyzing code patterns.
|
|
114
|
+
</Step>
|
|
115
|
+
|
|
116
|
+
<Step title="Choose a color">
|
|
117
|
+
Pick a background color for the subagent. This helps you identify which subagent is running in the UI.
|
|
118
|
+
</Step>
|
|
119
|
+
|
|
120
|
+
<Step title="Save and try it out">
|
|
121
|
+
Save the subagent. It's available immediately (no restart needed). Try it:
|
|
122
|
+
|
|
123
|
+
```text theme={null}
|
|
124
|
+
Use the code-improver agent to suggest improvements in this project
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
Claude delegates to your new subagent, which scans the codebase and returns improvement suggestions.
|
|
128
|
+
</Step>
|
|
129
|
+
</Steps>
|
|
130
|
+
|
|
131
|
+
You now have a subagent you can use in any project on your machine to analyze codebases and suggest improvements.
|
|
132
|
+
|
|
133
|
+
You can also create subagents manually as Markdown files, define them via CLI flags, or distribute them through plugins. The following sections cover all configuration options.
|
|
134
|
+
|
|
135
|
+
## Configure subagents
|
|
136
|
+
|
|
137
|
+
### Use the /agents command
|
|
138
|
+
|
|
139
|
+
The `/agents` command provides an interactive interface for managing subagents. Run `/agents` to:
|
|
140
|
+
|
|
141
|
+
* View all available subagents (built-in, user, project, and plugin)
|
|
142
|
+
* Create new subagents with guided setup or Claude generation
|
|
143
|
+
* Edit existing subagent configuration and tool access
|
|
144
|
+
* Delete custom subagents
|
|
145
|
+
* See which subagents are active when duplicates exist
|
|
146
|
+
|
|
147
|
+
This is the recommended way to create and manage subagents. For manual creation or automation, you can also add subagent files directly.
|
|
148
|
+
|
|
149
|
+
To list all configured subagents from the command line without starting an interactive session, run `claude agents`. This shows agents grouped by source and indicates which are overridden by higher-priority definitions.
|
|
150
|
+
|
|
151
|
+
### Choose the subagent scope
|
|
152
|
+
|
|
153
|
+
Subagents are Markdown files with YAML frontmatter. Store them in different locations depending on scope. When multiple subagents share the same name, the higher-priority location wins.
|
|
154
|
+
|
|
155
|
+
| Location | Scope | Priority | How to create |
|
|
156
|
+
| :--------------------------- | :---------------------- | :---------- | :------------------------------------ |
|
|
157
|
+
| `--agents` CLI flag | Current session | 1 (highest) | Pass JSON when launching Claude Code |
|
|
158
|
+
| `.claude/agents/` | Current project | 2 | Interactive or manual |
|
|
159
|
+
| `~/.claude/agents/` | All your projects | 3 | Interactive or manual |
|
|
160
|
+
| Plugin's `agents/` directory | Where plugin is enabled | 4 (lowest) | Installed with [plugins](/en/plugins) |
|
|
161
|
+
|
|
162
|
+
**Project subagents** (`.claude/agents/`) are ideal for subagents specific to a codebase. Check them into version control so your team can use and improve them collaboratively.
|
|
163
|
+
|
|
164
|
+
**User subagents** (`~/.claude/agents/`) are personal subagents available in all your projects.
|
|
165
|
+
|
|
166
|
+
**CLI-defined subagents** are passed as JSON when launching Claude Code. They exist only for that session and aren't saved to disk, making them useful for quick testing or automation scripts:
|
|
167
|
+
|
|
168
|
+
```bash theme={null}
|
|
169
|
+
claude --agents '{
|
|
170
|
+
"code-reviewer": {
|
|
171
|
+
"description": "Expert code reviewer. Use proactively after code changes.",
|
|
172
|
+
"prompt": "You are a senior code reviewer. Focus on code quality, security, and best practices.",
|
|
173
|
+
"tools": ["Read", "Grep", "Glob", "Bash"],
|
|
174
|
+
"model": "sonnet"
|
|
175
|
+
}
|
|
176
|
+
}'
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
The `--agents` flag accepts JSON with the same [frontmatter](#supported-frontmatter-fields) fields as file-based subagents: `description`, `prompt`, `tools`, `disallowedTools`, `model`, `permissionMode`, `mcpServers`, `hooks`, `maxTurns`, `skills`, and `memory`. Use `prompt` for the system prompt, equivalent to the markdown body in file-based subagents. See the [CLI reference](/en/cli-reference#agents-flag-format) for the full JSON format.
|
|
180
|
+
|
|
181
|
+
**Plugin subagents** come from [plugins](/en/plugins) you've installed. They appear in `/agents` alongside your custom subagents. See the [plugin components reference](/en/plugins-reference#agents) for details on creating plugin subagents.
|
|
182
|
+
|
|
183
|
+
### Write subagent files
|
|
184
|
+
|
|
185
|
+
Subagent files use YAML frontmatter for configuration, followed by the system prompt in Markdown:
|
|
186
|
+
|
|
187
|
+
<Note>
|
|
188
|
+
Subagents are loaded at session start. If you create a subagent by manually adding a file, restart your session or use `/agents` to load it immediately.
|
|
189
|
+
</Note>
|
|
190
|
+
|
|
191
|
+
```markdown theme={null}
|
|
192
|
+
---
|
|
193
|
+
name: code-reviewer
|
|
194
|
+
description: Reviews code for quality and best practices
|
|
195
|
+
tools: Read, Glob, Grep
|
|
196
|
+
model: sonnet
|
|
197
|
+
---
|
|
198
|
+
|
|
199
|
+
You are a code reviewer. When invoked, analyze the code and provide
|
|
200
|
+
specific, actionable feedback on quality, security, and best practices.
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
The frontmatter defines the subagent's metadata and configuration. The body becomes the system prompt that guides the subagent's behavior. Subagents receive only this system prompt (plus basic environment details like working directory), not the full Claude Code system prompt.
|
|
204
|
+
|
|
205
|
+
#### Supported frontmatter fields
|
|
206
|
+
|
|
207
|
+
The following fields can be used in the YAML frontmatter. Only `name` and `description` are required.
|
|
208
|
+
|
|
209
|
+
| Field | Required | Description |
|
|
210
|
+
| :---------------- | :------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
211
|
+
| `name` | Yes | Unique identifier using lowercase letters and hyphens |
|
|
212
|
+
| `description` | Yes | When Claude should delegate to this subagent |
|
|
213
|
+
| `tools` | No | [Tools](#available-tools) the subagent can use. Inherits all tools if omitted |
|
|
214
|
+
| `disallowedTools` | No | Tools to deny, removed from inherited or specified list |
|
|
215
|
+
| `model` | No | [Model](#choose-a-model) to use: `sonnet`, `opus`, `haiku`, or `inherit`. Defaults to `inherit` |
|
|
216
|
+
| `permissionMode` | No | [Permission mode](#permission-modes): `default`, `acceptEdits`, `dontAsk`, `bypassPermissions`, or `plan` |
|
|
217
|
+
| `maxTurns` | No | Maximum number of agentic turns before the subagent stops |
|
|
218
|
+
| `skills` | No | [Skills](/en/skills) to load into the subagent's context at startup. The full skill content is injected, not just made available for invocation. Subagents don't inherit skills from the parent conversation |
|
|
219
|
+
| `mcpServers` | No | [MCP servers](/en/mcp) available to this subagent. Each entry is either a server name referencing an already-configured server (e.g., `"slack"`) or an inline definition with the server name as key and a full [MCP server config](/en/mcp#configure-mcp-servers) as value |
|
|
220
|
+
| `hooks` | No | [Lifecycle hooks](#define-hooks-for-subagents) scoped to this subagent |
|
|
221
|
+
| `memory` | No | [Persistent memory scope](#enable-persistent-memory): `user`, `project`, or `local`. Enables cross-session learning |
|
|
222
|
+
| `background` | No | Set to `true` to always run this subagent as a [background task](#run-subagents-in-foreground-or-background). Default: `false` |
|
|
223
|
+
| `isolation` | No | Set to `worktree` to run the subagent in a temporary [git worktree](/en/common-workflows#run-parallel-claude-code-sessions-with-git-worktrees), giving it an isolated copy of the repository. The worktree is automatically cleaned up if the subagent makes no changes |
|
|
224
|
+
|
|
225
|
+
### Choose a model
|
|
226
|
+
|
|
227
|
+
The `model` field controls which [AI model](/en/model-config) the subagent uses:
|
|
228
|
+
|
|
229
|
+
* **Model alias**: Use one of the available aliases: `sonnet`, `opus`, or `haiku`
|
|
230
|
+
* **inherit**: Use the same model as the main conversation
|
|
231
|
+
* **Omitted**: If not specified, defaults to `inherit` (uses the same model as the main conversation)
|
|
232
|
+
|
|
233
|
+
### Control subagent capabilities
|
|
234
|
+
|
|
235
|
+
You can control what subagents can do through tool access, permission modes, and conditional rules.
|
|
236
|
+
|
|
237
|
+
#### Available tools
|
|
238
|
+
|
|
239
|
+
Subagents can use any of Claude Code's [internal tools](/en/settings#tools-available-to-claude). By default, subagents inherit all tools from the main conversation, including MCP tools.
|
|
240
|
+
|
|
241
|
+
To restrict tools, use the `tools` field (allowlist) or `disallowedTools` field (denylist):
|
|
242
|
+
|
|
243
|
+
```yaml theme={null}
|
|
244
|
+
---
|
|
245
|
+
name: safe-researcher
|
|
246
|
+
description: Research agent with restricted capabilities
|
|
247
|
+
tools: Read, Grep, Glob, Bash
|
|
248
|
+
disallowedTools: Write, Edit
|
|
249
|
+
---
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
#### Restrict which subagents can be spawned
|
|
253
|
+
|
|
254
|
+
When an agent runs as the main thread with `claude --agent`, it can spawn subagents using the Agent tool. To restrict which subagent types it can spawn, use `Agent(agent_type)` syntax in the `tools` field.
|
|
255
|
+
|
|
256
|
+
<Note>In version 2.1.63, the Task tool was renamed to Agent. Existing `Task(...)` references in settings and agent definitions still work as aliases.</Note>
|
|
257
|
+
|
|
258
|
+
```yaml theme={null}
|
|
259
|
+
---
|
|
260
|
+
name: coordinator
|
|
261
|
+
description: Coordinates work across specialized agents
|
|
262
|
+
tools: Agent(worker, researcher), Read, Bash
|
|
263
|
+
---
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
This is an allowlist: only the `worker` and `researcher` subagents can be spawned. If the agent tries to spawn any other type, the request fails and the agent sees only the allowed types in its prompt. To block specific agents while allowing all others, use [`permissions.deny`](#disable-specific-subagents) instead.
|
|
267
|
+
|
|
268
|
+
To allow spawning any subagent without restrictions, use `Agent` without parentheses:
|
|
269
|
+
|
|
270
|
+
```yaml theme={null}
|
|
271
|
+
tools: Agent, Read, Bash
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
If `Agent` is omitted from the `tools` list entirely, the agent cannot spawn any subagents. This restriction only applies to agents running as the main thread with `claude --agent`. Subagents cannot spawn other subagents, so `Agent(agent_type)` has no effect in subagent definitions.
|
|
275
|
+
|
|
276
|
+
#### Permission modes
|
|
277
|
+
|
|
278
|
+
The `permissionMode` field controls how the subagent handles permission prompts. Subagents inherit the permission context from the main conversation but can override the mode.
|
|
279
|
+
|
|
280
|
+
| Mode | Behavior |
|
|
281
|
+
| :------------------ | :----------------------------------------------------------------- |
|
|
282
|
+
| `default` | Standard permission checking with prompts |
|
|
283
|
+
| `acceptEdits` | Auto-accept file edits |
|
|
284
|
+
| `dontAsk` | Auto-deny permission prompts (explicitly allowed tools still work) |
|
|
285
|
+
| `bypassPermissions` | Skip all permission checks |
|
|
286
|
+
| `plan` | Plan mode (read-only exploration) |
|
|
287
|
+
|
|
288
|
+
<Warning>
|
|
289
|
+
Use `bypassPermissions` with caution. It skips all permission checks, allowing the subagent to execute any operation without approval.
|
|
290
|
+
</Warning>
|
|
291
|
+
|
|
292
|
+
If the parent uses `bypassPermissions`, this takes precedence and cannot be overridden.
|
|
293
|
+
|
|
294
|
+
#### Preload skills into subagents
|
|
295
|
+
|
|
296
|
+
Use the `skills` field to inject skill content into a subagent's context at startup. This gives the subagent domain knowledge without requiring it to discover and load skills during execution.
|
|
297
|
+
|
|
298
|
+
```yaml theme={null}
|
|
299
|
+
---
|
|
300
|
+
name: api-developer
|
|
301
|
+
description: Implement API endpoints following team conventions
|
|
302
|
+
skills:
|
|
303
|
+
- api-conventions
|
|
304
|
+
- error-handling-patterns
|
|
305
|
+
---
|
|
306
|
+
|
|
307
|
+
Implement API endpoints. Follow the conventions and patterns from the preloaded skills.
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
The full content of each skill is injected into the subagent's context, not just made available for invocation. Subagents don't inherit skills from the parent conversation; you must list them explicitly.
|
|
311
|
+
|
|
312
|
+
<Note>
|
|
313
|
+
This is the inverse of [running a skill in a subagent](/en/skills#run-skills-in-a-subagent). With `skills` in a subagent, the subagent controls the system prompt and loads skill content. With `context: fork` in a skill, the skill content is injected into the agent you specify. Both use the same underlying system.
|
|
314
|
+
</Note>
|
|
315
|
+
|
|
316
|
+
#### Enable persistent memory
|
|
317
|
+
|
|
318
|
+
The `memory` field gives the subagent a persistent directory that survives across conversations. The subagent uses this directory to build up knowledge over time, such as codebase patterns, debugging insights, and architectural decisions.
|
|
319
|
+
|
|
320
|
+
```yaml theme={null}
|
|
321
|
+
---
|
|
322
|
+
name: code-reviewer
|
|
323
|
+
description: Reviews code for quality and best practices
|
|
324
|
+
memory: user
|
|
325
|
+
---
|
|
326
|
+
|
|
327
|
+
You are a code reviewer. As you review code, update your agent memory with
|
|
328
|
+
patterns, conventions, and recurring issues you discover.
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
Choose a scope based on how broadly the memory should apply:
|
|
332
|
+
|
|
333
|
+
| Scope | Location | Use when |
|
|
334
|
+
| :-------- | :-------------------------------------------- | :------------------------------------------------------------------------------------------ |
|
|
335
|
+
| `user` | `~/.claude/agent-memory/<name-of-agent>/` | the subagent should remember learnings across all projects |
|
|
336
|
+
| `project` | `.claude/agent-memory/<name-of-agent>/` | the subagent's knowledge is project-specific and shareable via version control |
|
|
337
|
+
| `local` | `.claude/agent-memory-local/<name-of-agent>/` | the subagent's knowledge is project-specific but should not be checked into version control |
|
|
338
|
+
|
|
339
|
+
When memory is enabled:
|
|
340
|
+
|
|
341
|
+
* The subagent's system prompt includes instructions for reading and writing to the memory directory.
|
|
342
|
+
* The subagent's system prompt also includes the first 200 lines of `MEMORY.md` in the memory directory, with instructions to curate `MEMORY.md` if it exceeds 200 lines.
|
|
343
|
+
* Read, Write, and Edit tools are automatically enabled so the subagent can manage its memory files.
|
|
344
|
+
|
|
345
|
+
##### Persistent memory tips
|
|
346
|
+
|
|
347
|
+
* `user` is the recommended default scope. Use `project` or `local` when the subagent's knowledge is only relevant to a specific codebase.
|
|
348
|
+
* Ask the subagent to consult its memory before starting work: "Review this PR, and check your memory for patterns you've seen before."
|
|
349
|
+
* Ask the subagent to update its memory after completing a task: "Now that you're done, save what you learned to your memory." Over time, this builds a knowledge base that makes the subagent more effective.
|
|
350
|
+
* Include memory instructions directly in the subagent's markdown file so it proactively maintains its own knowledge base:
|
|
351
|
+
|
|
352
|
+
```markdown theme={null}
|
|
353
|
+
Update your agent memory as you discover codepaths, patterns, library
|
|
354
|
+
locations, and key architectural decisions. This builds up institutional
|
|
355
|
+
knowledge across conversations. Write concise notes about what you found
|
|
356
|
+
and where.
|
|
357
|
+
```
|
|
358
|
+
|
|
359
|
+
#### Conditional rules with hooks
|
|
360
|
+
|
|
361
|
+
For more dynamic control over tool usage, use `PreToolUse` hooks to validate operations before they execute. This is useful when you need to allow some operations of a tool while blocking others.
|
|
362
|
+
|
|
363
|
+
This example creates a subagent that only allows read-only database queries. The `PreToolUse` hook runs the script specified in `command` before each Bash command executes:
|
|
364
|
+
|
|
365
|
+
```yaml theme={null}
|
|
366
|
+
---
|
|
367
|
+
name: db-reader
|
|
368
|
+
description: Execute read-only database queries
|
|
369
|
+
tools: Bash
|
|
370
|
+
hooks:
|
|
371
|
+
PreToolUse:
|
|
372
|
+
- matcher: "Bash"
|
|
373
|
+
hooks:
|
|
374
|
+
- type: command
|
|
375
|
+
command: "./scripts/validate-readonly-query.sh"
|
|
376
|
+
---
|
|
377
|
+
```
|
|
378
|
+
|
|
379
|
+
Claude Code [passes hook input as JSON](/en/hooks#pretooluse-input) via stdin to hook commands. The validation script reads this JSON, extracts the Bash command, and [exits with code 2](/en/hooks#exit-code-2-behavior-per-event) to block write operations:
|
|
380
|
+
|
|
381
|
+
```bash theme={null}
|
|
382
|
+
#!/bin/bash
|
|
383
|
+
# ./scripts/validate-readonly-query.sh
|
|
384
|
+
|
|
385
|
+
INPUT=$(cat)
|
|
386
|
+
COMMAND=$(echo "$INPUT" | jq -r '.tool_input.command // empty')
|
|
387
|
+
|
|
388
|
+
# Block SQL write operations (case-insensitive)
|
|
389
|
+
if echo "$COMMAND" | grep -iE '\b(INSERT|UPDATE|DELETE|DROP|CREATE|ALTER|TRUNCATE)\b' > /dev/null; then
|
|
390
|
+
echo "Blocked: Only SELECT queries are allowed" >&2
|
|
391
|
+
exit 2
|
|
392
|
+
fi
|
|
393
|
+
|
|
394
|
+
exit 0
|
|
395
|
+
```
|
|
396
|
+
|
|
397
|
+
See [Hook input](/en/hooks#pretooluse-input) for the complete input schema and [exit codes](/en/hooks#exit-code-output) for how exit codes affect behavior.
|
|
398
|
+
|
|
399
|
+
#### Disable specific subagents
|
|
400
|
+
|
|
401
|
+
You can prevent Claude from using specific subagents by adding them to the `deny` array in your [settings](/en/settings#permission-settings). Use the format `Agent(subagent-name)` where `subagent-name` matches the subagent's name field.
|
|
402
|
+
|
|
403
|
+
```json theme={null}
|
|
404
|
+
{
|
|
405
|
+
"permissions": {
|
|
406
|
+
"deny": ["Agent(Explore)", "Agent(my-custom-agent)"]
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
```
|
|
410
|
+
|
|
411
|
+
This works for both built-in and custom subagents. You can also use the `--disallowedTools` CLI flag:
|
|
412
|
+
|
|
413
|
+
```bash theme={null}
|
|
414
|
+
claude --disallowedTools "Agent(Explore)"
|
|
415
|
+
```
|
|
416
|
+
|
|
417
|
+
See [Permissions documentation](/en/permissions#tool-specific-permission-rules) for more details on permission rules.
|
|
418
|
+
|
|
419
|
+
### Define hooks for subagents
|
|
420
|
+
|
|
421
|
+
Subagents can define [hooks](/en/hooks) that run during the subagent's lifecycle. There are two ways to configure hooks:
|
|
422
|
+
|
|
423
|
+
1. **In the subagent's frontmatter**: Define hooks that run only while that subagent is active
|
|
424
|
+
2. **In `settings.json`**: Define hooks that run in the main session when subagents start or stop
|
|
425
|
+
|
|
426
|
+
#### Hooks in subagent frontmatter
|
|
427
|
+
|
|
428
|
+
Define hooks directly in the subagent's markdown file. These hooks only run while that specific subagent is active and are cleaned up when it finishes.
|
|
429
|
+
|
|
430
|
+
All [hook events](/en/hooks#hook-events) are supported. The most common events for subagents are:
|
|
431
|
+
|
|
432
|
+
| Event | Matcher input | When it fires |
|
|
433
|
+
| :------------ | :------------ | :------------------------------------------------------------------ |
|
|
434
|
+
| `PreToolUse` | Tool name | Before the subagent uses a tool |
|
|
435
|
+
| `PostToolUse` | Tool name | After the subagent uses a tool |
|
|
436
|
+
| `Stop` | (none) | When the subagent finishes (converted to `SubagentStop` at runtime) |
|
|
437
|
+
|
|
438
|
+
This example validates Bash commands with the `PreToolUse` hook and runs a linter after file edits with `PostToolUse`:
|
|
439
|
+
|
|
440
|
+
```yaml theme={null}
|
|
441
|
+
---
|
|
442
|
+
name: code-reviewer
|
|
443
|
+
description: Review code changes with automatic linting
|
|
444
|
+
hooks:
|
|
445
|
+
PreToolUse:
|
|
446
|
+
- matcher: "Bash"
|
|
447
|
+
hooks:
|
|
448
|
+
- type: command
|
|
449
|
+
command: "./scripts/validate-command.sh $TOOL_INPUT"
|
|
450
|
+
PostToolUse:
|
|
451
|
+
- matcher: "Edit|Write"
|
|
452
|
+
hooks:
|
|
453
|
+
- type: command
|
|
454
|
+
command: "./scripts/run-linter.sh"
|
|
455
|
+
---
|
|
456
|
+
```
|
|
457
|
+
|
|
458
|
+
`Stop` hooks in frontmatter are automatically converted to `SubagentStop` events.
|
|
459
|
+
|
|
460
|
+
#### Project-level hooks for subagent events
|
|
461
|
+
|
|
462
|
+
Configure hooks in `settings.json` that respond to subagent lifecycle events in the main session.
|
|
463
|
+
|
|
464
|
+
| Event | Matcher input | When it fires |
|
|
465
|
+
| :-------------- | :-------------- | :------------------------------- |
|
|
466
|
+
| `SubagentStart` | Agent type name | When a subagent begins execution |
|
|
467
|
+
| `SubagentStop` | Agent type name | When a subagent completes |
|
|
468
|
+
|
|
469
|
+
Both events support matchers to target specific agent types by name. This example runs a setup script only when the `db-agent` subagent starts, and a cleanup script when any subagent stops:
|
|
470
|
+
|
|
471
|
+
```json theme={null}
|
|
472
|
+
{
|
|
473
|
+
"hooks": {
|
|
474
|
+
"SubagentStart": [
|
|
475
|
+
{
|
|
476
|
+
"matcher": "db-agent",
|
|
477
|
+
"hooks": [
|
|
478
|
+
{ "type": "command", "command": "./scripts/setup-db-connection.sh" }
|
|
479
|
+
]
|
|
480
|
+
}
|
|
481
|
+
],
|
|
482
|
+
"SubagentStop": [
|
|
483
|
+
{
|
|
484
|
+
"hooks": [
|
|
485
|
+
{ "type": "command", "command": "./scripts/cleanup-db-connection.sh" }
|
|
486
|
+
]
|
|
487
|
+
}
|
|
488
|
+
]
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
```
|
|
492
|
+
|
|
493
|
+
See [Hooks](/en/hooks) for the complete hook configuration format.
|
|
494
|
+
|
|
495
|
+
## Work with subagents
|
|
496
|
+
|
|
497
|
+
### Understand automatic delegation
|
|
498
|
+
|
|
499
|
+
Claude automatically delegates tasks based on the task description in your request, the `description` field in subagent configurations, and current context. To encourage proactive delegation, include phrases like "use proactively" in your subagent's description field.
|
|
500
|
+
|
|
501
|
+
You can also request a specific subagent explicitly:
|
|
502
|
+
|
|
503
|
+
```text theme={null}
|
|
504
|
+
Use the test-runner subagent to fix failing tests
|
|
505
|
+
Have the code-reviewer subagent look at my recent changes
|
|
506
|
+
```
|
|
507
|
+
|
|
508
|
+
### Run subagents in foreground or background
|
|
509
|
+
|
|
510
|
+
Subagents can run in the foreground (blocking) or background (concurrent):
|
|
511
|
+
|
|
512
|
+
* **Foreground subagents** block the main conversation until complete. Permission prompts and clarifying questions (like [`AskUserQuestion`](/en/settings#tools-available-to-claude)) are passed through to you.
|
|
513
|
+
* **Background subagents** run concurrently while you continue working. Before launching, Claude Code prompts for any tool permissions the subagent will need, ensuring it has the necessary approvals upfront. Once running, the subagent inherits these permissions and auto-denies anything not pre-approved. If a background subagent needs to ask clarifying questions, that tool call fails but the subagent continues.
|
|
514
|
+
|
|
515
|
+
If a background subagent fails due to missing permissions, you can [resume it](#resume-subagents) in the foreground to retry with interactive prompts.
|
|
516
|
+
|
|
517
|
+
Claude decides whether to run subagents in the foreground or background based on the task. You can also:
|
|
518
|
+
|
|
519
|
+
* Ask Claude to "run this in the background"
|
|
520
|
+
* Press **Ctrl+B** to background a running task
|
|
521
|
+
|
|
522
|
+
To disable all background task functionality, set the `CLAUDE_CODE_DISABLE_BACKGROUND_TASKS` environment variable to `1`. See [Environment variables](/en/settings#environment-variables).
|
|
523
|
+
|
|
524
|
+
### Common patterns
|
|
525
|
+
|
|
526
|
+
#### Isolate high-volume operations
|
|
527
|
+
|
|
528
|
+
One of the most effective uses for subagents is isolating operations that produce large amounts of output. Running tests, fetching documentation, or processing log files can consume significant context. By delegating these to a subagent, the verbose output stays in the subagent's context while only the relevant summary returns to your main conversation.
|
|
529
|
+
|
|
530
|
+
```text theme={null}
|
|
531
|
+
Use a subagent to run the test suite and report only the failing tests with their error messages
|
|
532
|
+
```
|
|
533
|
+
|
|
534
|
+
#### Run parallel research
|
|
535
|
+
|
|
536
|
+
For independent investigations, spawn multiple subagents to work simultaneously:
|
|
537
|
+
|
|
538
|
+
```text theme={null}
|
|
539
|
+
Research the authentication, database, and API modules in parallel using separate subagents
|
|
540
|
+
```
|
|
541
|
+
|
|
542
|
+
Each subagent explores its area independently, then Claude synthesizes the findings. This works best when the research paths don't depend on each other.
|
|
543
|
+
|
|
544
|
+
<Warning>
|
|
545
|
+
When subagents complete, their results return to your main conversation. Running many subagents that each return detailed results can consume significant context.
|
|
546
|
+
</Warning>
|
|
547
|
+
|
|
548
|
+
For tasks that need sustained parallelism or exceed your context window, [agent teams](/en/agent-teams) give each worker its own independent context.
|
|
549
|
+
|
|
550
|
+
#### Chain subagents
|
|
551
|
+
|
|
552
|
+
For multi-step workflows, ask Claude to use subagents in sequence. Each subagent completes its task and returns results to Claude, which then passes relevant context to the next subagent.
|
|
553
|
+
|
|
554
|
+
```text theme={null}
|
|
555
|
+
Use the code-reviewer subagent to find performance issues, then use the optimizer subagent to fix them
|
|
556
|
+
```
|
|
557
|
+
|
|
558
|
+
### Choose between subagents and main conversation
|
|
559
|
+
|
|
560
|
+
Use the **main conversation** when:
|
|
561
|
+
|
|
562
|
+
* The task needs frequent back-and-forth or iterative refinement
|
|
563
|
+
* Multiple phases share significant context (planning → implementation → testing)
|
|
564
|
+
* You're making a quick, targeted change
|
|
565
|
+
* Latency matters. Subagents start fresh and may need time to gather context
|
|
566
|
+
|
|
567
|
+
Use **subagents** when:
|
|
568
|
+
|
|
569
|
+
* The task produces verbose output you don't need in your main context
|
|
570
|
+
* You want to enforce specific tool restrictions or permissions
|
|
571
|
+
* The work is self-contained and can return a summary
|
|
572
|
+
|
|
573
|
+
Consider [Skills](/en/skills) instead when you want reusable prompts or workflows that run in the main conversation context rather than isolated subagent context.
|
|
574
|
+
|
|
575
|
+
<Note>
|
|
576
|
+
Subagents cannot spawn other subagents. If your workflow requires nested delegation, use [Skills](/en/skills) or [chain subagents](#chain-subagents) from the main conversation.
|
|
577
|
+
</Note>
|
|
578
|
+
|
|
579
|
+
### Manage subagent context
|
|
580
|
+
|
|
581
|
+
#### Resume subagents
|
|
582
|
+
|
|
583
|
+
Each subagent invocation creates a new instance with fresh context. To continue an existing subagent's work instead of starting over, ask Claude to resume it.
|
|
584
|
+
|
|
585
|
+
Resumed subagents retain their full conversation history, including all previous tool calls, results, and reasoning. The subagent picks up exactly where it stopped rather than starting fresh.
|
|
586
|
+
|
|
587
|
+
When a subagent completes, Claude receives its agent ID. To resume a subagent, ask Claude to continue the previous work:
|
|
588
|
+
|
|
589
|
+
```text theme={null}
|
|
590
|
+
Use the code-reviewer subagent to review the authentication module
|
|
591
|
+
[Agent completes]
|
|
592
|
+
|
|
593
|
+
Continue that code review and now analyze the authorization logic
|
|
594
|
+
[Claude resumes the subagent with full context from previous conversation]
|
|
595
|
+
```
|
|
596
|
+
|
|
597
|
+
You can also ask Claude for the agent ID if you want to reference it explicitly, or find IDs in the transcript files at `~/.claude/projects/{project}/{sessionId}/subagents/`. Each transcript is stored as `agent-{agentId}.jsonl`.
|
|
598
|
+
|
|
599
|
+
Subagent transcripts persist independently of the main conversation:
|
|
600
|
+
|
|
601
|
+
* **Main conversation compaction**: When the main conversation compacts, subagent transcripts are unaffected. They're stored in separate files.
|
|
602
|
+
* **Session persistence**: Subagent transcripts persist within their session. You can [resume a subagent](#resume-subagents) after restarting Claude Code by resuming the same session.
|
|
603
|
+
* **Automatic cleanup**: Transcripts are cleaned up based on the `cleanupPeriodDays` setting (default: 30 days).
|
|
604
|
+
|
|
605
|
+
#### Auto-compaction
|
|
606
|
+
|
|
607
|
+
Subagents support automatic compaction using the same logic as the main conversation. By default, auto-compaction triggers at approximately 95% capacity. To trigger compaction earlier, set `CLAUDE_AUTOCOMPACT_PCT_OVERRIDE` to a lower percentage (for example, `50`). See [environment variables](/en/settings#environment-variables) for details.
|
|
608
|
+
|
|
609
|
+
Compaction events are logged in subagent transcript files:
|
|
610
|
+
|
|
611
|
+
```json theme={null}
|
|
612
|
+
{
|
|
613
|
+
"type": "system",
|
|
614
|
+
"subtype": "compact_boundary",
|
|
615
|
+
"compactMetadata": {
|
|
616
|
+
"trigger": "auto",
|
|
617
|
+
"preTokens": 167189
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
```
|
|
621
|
+
|
|
622
|
+
The `preTokens` value shows how many tokens were used before compaction occurred.
|
|
623
|
+
|
|
624
|
+
## Example subagents
|
|
625
|
+
|
|
626
|
+
These examples demonstrate effective patterns for building subagents. Use them as starting points, or generate a customized version with Claude.
|
|
627
|
+
|
|
628
|
+
<Tip>
|
|
629
|
+
**Best practices:**
|
|
630
|
+
|
|
631
|
+
* **Design focused subagents:** each subagent should excel at one specific task
|
|
632
|
+
* **Write detailed descriptions:** Claude uses the description to decide when to delegate
|
|
633
|
+
* **Limit tool access:** grant only necessary permissions for security and focus
|
|
634
|
+
* **Check into version control:** share project subagents with your team
|
|
635
|
+
</Tip>
|
|
636
|
+
|
|
637
|
+
### Code reviewer
|
|
638
|
+
|
|
639
|
+
A read-only subagent that reviews code without modifying it. This example shows how to design a focused subagent with limited tool access (no Edit or Write) and a detailed prompt that specifies exactly what to look for and how to format output.
|
|
640
|
+
|
|
641
|
+
```markdown theme={null}
|
|
642
|
+
---
|
|
643
|
+
name: code-reviewer
|
|
644
|
+
description: Expert code review specialist. Proactively reviews code for quality, security, and maintainability. Use immediately after writing or modifying code.
|
|
645
|
+
tools: Read, Grep, Glob, Bash
|
|
646
|
+
model: inherit
|
|
647
|
+
---
|
|
648
|
+
|
|
649
|
+
You are a senior code reviewer ensuring high standards of code quality and security.
|
|
650
|
+
|
|
651
|
+
When invoked:
|
|
652
|
+
1. Run git diff to see recent changes
|
|
653
|
+
2. Focus on modified files
|
|
654
|
+
3. Begin review immediately
|
|
655
|
+
|
|
656
|
+
Review checklist:
|
|
657
|
+
- Code is clear and readable
|
|
658
|
+
- Functions and variables are well-named
|
|
659
|
+
- No duplicated code
|
|
660
|
+
- Proper error handling
|
|
661
|
+
- No exposed secrets or API keys
|
|
662
|
+
- Input validation implemented
|
|
663
|
+
- Good test coverage
|
|
664
|
+
- Performance considerations addressed
|
|
665
|
+
|
|
666
|
+
Provide feedback organized by priority:
|
|
667
|
+
- Critical issues (must fix)
|
|
668
|
+
- Warnings (should fix)
|
|
669
|
+
- Suggestions (consider improving)
|
|
670
|
+
|
|
671
|
+
Include specific examples of how to fix issues.
|
|
672
|
+
```
|
|
673
|
+
|
|
674
|
+
### Debugger
|
|
675
|
+
|
|
676
|
+
A subagent that can both analyze and fix issues. Unlike the code reviewer, this one includes Edit because fixing bugs requires modifying code. The prompt provides a clear workflow from diagnosis to verification.
|
|
677
|
+
|
|
678
|
+
```markdown theme={null}
|
|
679
|
+
---
|
|
680
|
+
name: debugger
|
|
681
|
+
description: Debugging specialist for errors, test failures, and unexpected behavior. Use proactively when encountering any issues.
|
|
682
|
+
tools: Read, Edit, Bash, Grep, Glob
|
|
683
|
+
---
|
|
684
|
+
|
|
685
|
+
You are an expert debugger specializing in root cause analysis.
|
|
686
|
+
|
|
687
|
+
When invoked:
|
|
688
|
+
1. Capture error message and stack trace
|
|
689
|
+
2. Identify reproduction steps
|
|
690
|
+
3. Isolate the failure location
|
|
691
|
+
4. Implement minimal fix
|
|
692
|
+
5. Verify solution works
|
|
693
|
+
|
|
694
|
+
Debugging process:
|
|
695
|
+
- Analyze error messages and logs
|
|
696
|
+
- Check recent code changes
|
|
697
|
+
- Form and test hypotheses
|
|
698
|
+
- Add strategic debug logging
|
|
699
|
+
- Inspect variable states
|
|
700
|
+
|
|
701
|
+
For each issue, provide:
|
|
702
|
+
- Root cause explanation
|
|
703
|
+
- Evidence supporting the diagnosis
|
|
704
|
+
- Specific code fix
|
|
705
|
+
- Testing approach
|
|
706
|
+
- Prevention recommendations
|
|
707
|
+
|
|
708
|
+
Focus on fixing the underlying issue, not the symptoms.
|
|
709
|
+
```
|
|
710
|
+
|
|
711
|
+
### Data scientist
|
|
712
|
+
|
|
713
|
+
A domain-specific subagent for data analysis work. This example shows how to create subagents for specialized workflows outside of typical coding tasks. It explicitly sets `model: sonnet` for more capable analysis.
|
|
714
|
+
|
|
715
|
+
```markdown theme={null}
|
|
716
|
+
---
|
|
717
|
+
name: data-scientist
|
|
718
|
+
description: Data analysis expert for SQL queries, BigQuery operations, and data insights. Use proactively for data analysis tasks and queries.
|
|
719
|
+
tools: Bash, Read, Write
|
|
720
|
+
model: sonnet
|
|
721
|
+
---
|
|
722
|
+
|
|
723
|
+
You are a data scientist specializing in SQL and BigQuery analysis.
|
|
724
|
+
|
|
725
|
+
When invoked:
|
|
726
|
+
1. Understand the data analysis requirement
|
|
727
|
+
2. Write efficient SQL queries
|
|
728
|
+
3. Use BigQuery command line tools (bq) when appropriate
|
|
729
|
+
4. Analyze and summarize results
|
|
730
|
+
5. Present findings clearly
|
|
731
|
+
|
|
732
|
+
Key practices:
|
|
733
|
+
- Write optimized SQL queries with proper filters
|
|
734
|
+
- Use appropriate aggregations and joins
|
|
735
|
+
- Include comments explaining complex logic
|
|
736
|
+
- Format results for readability
|
|
737
|
+
- Provide data-driven recommendations
|
|
738
|
+
|
|
739
|
+
For each analysis:
|
|
740
|
+
- Explain the query approach
|
|
741
|
+
- Document any assumptions
|
|
742
|
+
- Highlight key findings
|
|
743
|
+
- Suggest next steps based on data
|
|
744
|
+
|
|
745
|
+
Always ensure queries are efficient and cost-effective.
|
|
746
|
+
```
|
|
747
|
+
|
|
748
|
+
### Database query validator
|
|
749
|
+
|
|
750
|
+
A subagent that allows Bash access but validates commands to permit only read-only SQL queries. This example shows how to use `PreToolUse` hooks for conditional validation when you need finer control than the `tools` field provides.
|
|
751
|
+
|
|
752
|
+
```markdown theme={null}
|
|
753
|
+
---
|
|
754
|
+
name: db-reader
|
|
755
|
+
description: Execute read-only database queries. Use when analyzing data or generating reports.
|
|
756
|
+
tools: Bash
|
|
757
|
+
hooks:
|
|
758
|
+
PreToolUse:
|
|
759
|
+
- matcher: "Bash"
|
|
760
|
+
hooks:
|
|
761
|
+
- type: command
|
|
762
|
+
command: "./scripts/validate-readonly-query.sh"
|
|
763
|
+
---
|
|
764
|
+
|
|
765
|
+
You are a database analyst with read-only access. Execute SELECT queries to answer questions about the data.
|
|
766
|
+
|
|
767
|
+
When asked to analyze data:
|
|
768
|
+
1. Identify which tables contain the relevant data
|
|
769
|
+
2. Write efficient SELECT queries with appropriate filters
|
|
770
|
+
3. Present results clearly with context
|
|
771
|
+
|
|
772
|
+
You cannot modify data. If asked to INSERT, UPDATE, DELETE, or modify schema, explain that you only have read access.
|
|
773
|
+
```
|
|
774
|
+
|
|
775
|
+
Claude Code [passes hook input as JSON](/en/hooks#pretooluse-input) via stdin to hook commands. The validation script reads this JSON, extracts the command being executed, and checks it against a list of SQL write operations. If a write operation is detected, the script [exits with code 2](/en/hooks#exit-code-2-behavior-per-event) to block execution and returns an error message to Claude via stderr.
|
|
776
|
+
|
|
777
|
+
Create the validation script anywhere in your project. The path must match the `command` field in your hook configuration:
|
|
778
|
+
|
|
779
|
+
```bash theme={null}
|
|
780
|
+
#!/bin/bash
|
|
781
|
+
# Blocks SQL write operations, allows SELECT queries
|
|
782
|
+
|
|
783
|
+
# Read JSON input from stdin
|
|
784
|
+
INPUT=$(cat)
|
|
785
|
+
|
|
786
|
+
# Extract the command field from tool_input using jq
|
|
787
|
+
COMMAND=$(echo "$INPUT" | jq -r '.tool_input.command // empty')
|
|
788
|
+
|
|
789
|
+
if [ -z "$COMMAND" ]; then
|
|
790
|
+
exit 0
|
|
791
|
+
fi
|
|
792
|
+
|
|
793
|
+
# Block write operations (case-insensitive)
|
|
794
|
+
if echo "$COMMAND" | grep -iE '\b(INSERT|UPDATE|DELETE|DROP|CREATE|ALTER|TRUNCATE|REPLACE|MERGE)\b' > /dev/null; then
|
|
795
|
+
echo "Blocked: Write operations not allowed. Use SELECT queries only." >&2
|
|
796
|
+
exit 2
|
|
797
|
+
fi
|
|
798
|
+
|
|
799
|
+
exit 0
|
|
800
|
+
```
|
|
801
|
+
|
|
802
|
+
Make the script executable:
|
|
803
|
+
|
|
804
|
+
```bash theme={null}
|
|
805
|
+
chmod +x ./scripts/validate-readonly-query.sh
|
|
806
|
+
```
|
|
807
|
+
|
|
808
|
+
The hook receives JSON via stdin with the Bash command in `tool_input.command`. Exit code 2 blocks the operation and feeds the error message back to Claude. See [Hooks](/en/hooks#exit-code-output) for details on exit codes and [Hook input](/en/hooks#pretooluse-input) for the complete input schema.
|
|
809
|
+
|
|
810
|
+
## Next steps
|
|
811
|
+
|
|
812
|
+
Now that you understand subagents, explore these related features:
|
|
813
|
+
|
|
814
|
+
* [Distribute subagents with plugins](/en/plugins) to share subagents across teams or projects
|
|
815
|
+
* [Run Claude Code programmatically](/en/headless) with the Agent SDK for CI/CD and automation
|
|
816
|
+
* [Use MCP servers](/en/mcp) to give subagents access to external tools and data
|