rhachet-roles-bhrain 0.1.1 → 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/dist/.test/getContextOpenAI.js +1 -1
- package/dist/.test/getContextOpenAI.js.map +1 -1
- package/dist/domain.operations/review/compileReviewPrompt.d.ts +22 -0
- package/dist/domain.operations/review/compileReviewPrompt.js +95 -0
- package/dist/domain.operations/review/compileReviewPrompt.js.map +1 -0
- package/dist/domain.operations/review/enumFilesFromDiffs.d.ts +8 -0
- package/dist/domain.operations/review/enumFilesFromDiffs.js +74 -0
- package/dist/domain.operations/review/enumFilesFromDiffs.js.map +1 -0
- package/dist/domain.operations/review/enumFilesFromGlob.d.ts +8 -0
- package/dist/domain.operations/review/enumFilesFromGlob.js +31 -0
- package/dist/domain.operations/review/enumFilesFromGlob.js.map +1 -0
- package/dist/domain.operations/review/estimateTokenCount.d.ts +9 -0
- package/dist/domain.operations/review/estimateTokenCount.js +20 -0
- package/dist/domain.operations/review/estimateTokenCount.js.map +1 -0
- package/dist/domain.operations/review/formatReviewOutput.d.ts +14 -0
- package/dist/domain.operations/review/formatReviewOutput.js +42 -0
- package/dist/domain.operations/review/formatReviewOutput.js.map +1 -0
- package/dist/domain.operations/review/genTokenBreakdownMarkdown.d.ts +19 -0
- package/dist/domain.operations/review/genTokenBreakdownMarkdown.js +110 -0
- package/dist/domain.operations/review/genTokenBreakdownMarkdown.js.map +1 -0
- package/dist/domain.operations/review/genTokenBreakdownReport.d.ts +24 -0
- package/dist/domain.operations/review/genTokenBreakdownReport.js +64 -0
- package/dist/domain.operations/review/genTokenBreakdownReport.js.map +1 -0
- package/dist/domain.operations/review/invokeClaudeCode.d.ts +22 -0
- package/dist/domain.operations/review/invokeClaudeCode.js +92 -0
- package/dist/domain.operations/review/invokeClaudeCode.js.map +1 -0
- package/dist/domain.operations/review/writeInputArtifacts.d.ts +27 -0
- package/dist/domain.operations/review/writeInputArtifacts.js +50 -0
- package/dist/domain.operations/review/writeInputArtifacts.js.map +1 -0
- package/dist/domain.operations/review/writeOutputArtifacts.d.ts +12 -0
- package/dist/domain.operations/review/writeOutputArtifacts.js +46 -0
- package/dist/domain.operations/review/writeOutputArtifacts.js.map +1 -0
- package/dist/roles/architect/briefs/brains.replic/arc000.sources.[catalog].md +178 -0
- package/dist/roles/architect/briefs/brains.replic/arc101.concept.llm.[article].md +25 -0
- package/dist/roles/architect/briefs/brains.replic/arc102.concept.repl.[article].md +33 -0
- package/dist/roles/architect/briefs/brains.replic/arc103.concept.replic-brain.[article].md +35 -0
- package/dist/roles/architect/briefs/brains.replic/arc104.concept.context-window.[article].md +40 -0
- package/dist/roles/architect/briefs/brains.replic/arc105.concept.system-prompt.[article].md +44 -0
- package/dist/roles/architect/briefs/brains.replic/arc106.concept.tool-definition.[article].md +59 -0
- package/dist/roles/architect/briefs/brains.replic/arc107.concept.tool-call.[article].md +54 -0
- package/dist/roles/architect/briefs/brains.replic/arc108.concept.tool-result.[article].md +58 -0
- package/dist/roles/architect/briefs/brains.replic/arc109.concept.agentic-loop.[article].md +62 -0
- package/dist/roles/architect/briefs/brains.replic/arc110.concept.reasoning-trace.[article].md +58 -0
- package/dist/roles/architect/briefs/brains.replic/arc111.concept.react-pattern.[article].md +65 -0
- package/dist/roles/architect/briefs/brains.replic/arc112.concept.reflexion-pattern.[article].md +68 -0
- package/dist/roles/architect/briefs/brains.replic/arc113.concept.tree-of-thoughts.[article].md +76 -0
- package/dist/roles/architect/briefs/brains.replic/arc114.concept.self-consistency.[article].md +73 -0
- package/dist/roles/architect/briefs/brains.replic/arc115.concept.lats-pattern.[article].md +78 -0
- package/dist/roles/architect/briefs/brains.replic/arc116.concept.context-compaction.[article].md +71 -0
- package/dist/roles/architect/briefs/brains.replic/arc117.concept.subagent.[article].md +71 -0
- package/dist/roles/architect/briefs/brains.replic/arc118.concept.extended-thinking.[article].md +69 -0
- package/dist/roles/architect/briefs/brains.replic/arc119.concept.mcp.[article].md +78 -0
- package/dist/roles/architect/briefs/brains.replic/arc120.concept.session.[article].md +67 -0
- package/dist/roles/architect/briefs/brains.replic/arc121.concept.message.[article].md +79 -0
- package/dist/roles/architect/briefs/brains.replic/arc122.concept.plan-and-solve.[article].md +80 -0
- package/dist/roles/architect/briefs/brains.replic/arc150.concepts.treestruct.[article].md +126 -0
- package/dist/roles/architect/briefs/brains.replic/arc201.blueprint.claude-code.[article].md +417 -0
- package/dist/roles/architect/briefs/brains.replic/arc201.blueprint.claude-code.zoomin.reason.[article].md +507 -0
- package/dist/roles/architect/briefs/brains.replic/arc202.blueprint.codex.[article].md +354 -0
- package/dist/roles/architect/briefs/brains.replic/arc300.blueprints.comparison.[catalog].md +284 -0
- package/dist/roles/getRoleRegistry.js +2 -1
- package/dist/roles/getRoleRegistry.js.map +1 -1
- package/dist/roles/getRoleRegistry.readme.js +6 -0
- package/dist/roles/getRoleRegistry.readme.js.map +1 -1
- package/dist/roles/reviewer/briefs/review.tactics.md +60 -0
- package/dist/roles/reviewer/getReviewerRole.d.ts +6 -0
- package/dist/roles/reviewer/getReviewerRole.js +80 -0
- package/dist/roles/reviewer/getReviewerRole.js.map +1 -0
- package/dist/roles/reviewer/skills/review/review.d.ts +57 -0
- package/dist/roles/reviewer/skills/review/review.js +445 -0
- package/dist/roles/reviewer/skills/review/review.js.map +1 -0
- package/dist/roles/reviewer/skills/review/review.sh +21 -0
- package/dist/roles/reviewer/skills/review/review.ts +575 -0
- package/dist/roles/thinker/briefs/term=brain.atomic_vs_replic.md +8 -0
- package/dist/roles/thinker/getThinkerRole.js +1 -1
- package/dist/roles/thinker/getThinkerRole.js.map +1 -1
- package/dist/roles/thinker/skills/brief.articulate/.demo/article.vision.v2025_08_19..i1.via_chatgpt.md +47 -0
- package/dist/roles/thinker/skills/brief.articulate/.demo/article.vision.v2025_08_19.i2.via_rhachet.md +60 -0
- package/dist/roles/thinker/skills/brief.articulate/.demo/diverge.v2025_08_17.i1.md +62 -0
- package/dist/roles/thinker/skills/brief.articulate/.demo/diverge.v2025_08_17.i1.with_feedback.md +89 -0
- package/dist/roles/thinker/skills/brief.articulate/.demo/diverge.v2025_08_17.i2.md +47 -0
- package/dist/roles/thinker/skills/brief.articulate/.demo/joke.v2025_08_15.i1.md +44 -0
- package/dist/roles/thinker/skills/brief.articulate/.demo/joke.v2025_08_15.i2.md +63 -0
- package/dist/roles/thinker/skills/brief.articulate/.demo/joke.v2025_08_15.i3.md +51 -0
- package/dist/roles/thinker/skills/brief.articulate/.demo/user-journey.v2025_08_17.i1.md +62 -0
- package/dist/roles/thinker/skills/brief.articulate/.demo/user-journey.v2025_08_17.i2.md +49 -0
- package/dist/roles/thinker/skills/brief.articulate/.readme.md +0 -0
- package/dist/roles/thinker/skills/brief.articulate/stepArticulate.skill.js +1 -1
- package/dist/roles/thinker/skills/brief.articulate/stepArticulate.skill.js.map +1 -1
- package/dist/roles/thinker/skills/brief.articulate/stepArticulate.skill.ts +168 -0
- package/dist/roles/thinker/skills/brief.articulate/stepArticulate.ts +157 -0
- package/dist/roles/thinker/skills/brief.catalogize/.demo/joke.types.v2025_08_28.i1.md +93 -0
- package/dist/roles/thinker/skills/brief.catalogize/.demo/joke.types.v2025_08_28.i2.md +84 -0
- package/dist/roles/thinker/skills/brief.catalogize/.demo/joke.types.v2025_09_28.i1.no_focus_context.md +8 -0
- package/dist/roles/thinker/skills/brief.catalogize/.demo/joke.types.v2025_09_28.i2.md +54 -0
- package/dist/roles/thinker/skills/brief.catalogize/.demo/persona.usecases.v2025_08_28.i1.md +62 -0
- package/dist/roles/thinker/skills/brief.catalogize/.demo/persona.usecases.v2025_08_28.i2.md +64 -0
- package/dist/roles/thinker/skills/brief.catalogize/.readme.md +5 -0
- package/dist/roles/thinker/skills/brief.catalogize/stepCatalogize.skill.js +1 -1
- package/dist/roles/thinker/skills/brief.catalogize/stepCatalogize.skill.js.map +1 -1
- package/dist/roles/thinker/skills/brief.catalogize/stepCatalogize.skill.ts +173 -0
- package/dist/roles/thinker/skills/brief.catalogize/stepCatalogize.ts +132 -0
- package/dist/roles/thinker/skills/brief.demonstrate/.demo/user.journey.roadtrip.input.example.i4.md +3 -0
- package/dist/roles/thinker/skills/brief.demonstrate/.demo/user.journey.roadtrip.input.example.i5.md +3 -0
- package/dist/roles/thinker/skills/brief.demonstrate/.demo/user.journey.roadtrip.input.example.i6.md +3 -0
- package/dist/roles/thinker/skills/brief.demonstrate/.demo/user.journey.roadtrip.input.example.md +3 -0
- package/dist/roles/thinker/skills/brief.demonstrate/.demo/user.journey.roadtrip.v2025_08_27.i1.md +52 -0
- package/dist/roles/thinker/skills/brief.demonstrate/.demo/user.journey.roadtrip.v2025_08_27.i2.md +51 -0
- package/dist/roles/thinker/skills/brief.demonstrate/.demo/user.journey.roadtrip.v2025_08_27.i3.md +47 -0
- package/dist/roles/thinker/skills/brief.demonstrate/.demo/user.journey.roadtrip.v2025_08_27.i4.md +62 -0
- package/dist/roles/thinker/skills/brief.demonstrate/.demo/user.journey.roadtrip.v2025_08_27.i5.md +47 -0
- package/dist/roles/thinker/skills/brief.demonstrate/.demo/user.journey.roadtrip.v2025_08_27.i6.md +53 -0
- package/dist/roles/thinker/skills/brief.demonstrate/.readme +3 -0
- package/dist/roles/thinker/skills/brief.demonstrate/stepDemonstrate.skill.js +1 -1
- package/dist/roles/thinker/skills/brief.demonstrate/stepDemonstrate.skill.js.map +1 -1
- package/dist/roles/thinker/skills/brief.demonstrate/stepDemonstrate.skill.ts +190 -0
- package/dist/roles/thinker/skills/brief.demonstrate/stepDemonstrate.ts +164 -0
- package/dist/roles/thinker/skills/khue.cluster/.demo/user.journeys.input1.cluster.v2025_08_17.i1.md +72 -0
- package/dist/roles/thinker/skills/khue.cluster/.demo/user.journeys.input1.cluster.v2025_08_17.i2.md +53 -0
- package/dist/roles/thinker/skills/khue.cluster/.demo/user.journeys.input1.cluster.v2025_08_17.i3.which_objectives.md +58 -0
- package/dist/roles/thinker/skills/khue.cluster/.demo/user.journeys.input1.cluster.v2025_08_17.i5.which_personas.md +64 -0
- package/dist/roles/thinker/skills/khue.cluster/.demo/user.journeys.input2.cluster.v2025_08_17.i1.md +67 -0
- package/dist/roles/thinker/skills/khue.cluster/.demo/user.journeys.input2.cluster.v2025_08_17.i2.md +49 -0
- package/dist/roles/thinker/skills/khue.cluster/.demo/user.journeys.input2.cluster.v2025_08_17.i3.md +59 -0
- package/dist/roles/thinker/skills/khue.cluster/.readme.md +0 -0
- package/dist/roles/thinker/skills/khue.cluster/stepCluster.skill.js +1 -1
- package/dist/roles/thinker/skills/khue.cluster/stepCluster.skill.js.map +1 -1
- package/dist/roles/thinker/skills/khue.cluster/stepCluster.skill.ts +174 -0
- package/dist/roles/thinker/skills/khue.cluster/stepCluster.ts +150 -0
- package/dist/roles/thinker/skills/khue.decompose/.readme.md +9 -0
- package/dist/roles/thinker/skills/khue.diverge/.demo/joke.examples.v2025_08_17.i2.md +23 -0
- package/dist/roles/thinker/skills/khue.diverge/.demo/joke.examples.v2025_08_17.i3.md +23 -0
- package/dist/roles/thinker/skills/khue.diverge/.demo/joke.varieties.v2025_08_17.i1.md +23 -0
- package/dist/roles/thinker/skills/khue.diverge/.demo/userjourney.examples.v2025_08_17.i1.md +9 -0
- package/dist/roles/thinker/skills/khue.diverge/.demo/userjourney.examples.v2025_08_17.i2.md +9 -0
- package/dist/roles/thinker/skills/khue.diverge/.demo/userjourney.examples.v2025_08_17.i3.md +23 -0
- package/dist/roles/thinker/skills/khue.diverge/.demo/userjourney.examples.v2025_08_17.i4.folksy.md +9 -0
- package/dist/roles/thinker/skills/khue.diverge/.demo/userjourney.examples.v2025_08_17.i5.folksy.md +23 -0
- package/dist/roles/thinker/skills/khue.diverge/.readme.md +0 -0
- package/dist/roles/thinker/skills/khue.diverge/stepDiverge.skill.js +1 -1
- package/dist/roles/thinker/skills/khue.diverge/stepDiverge.skill.js.map +1 -1
- package/dist/roles/thinker/skills/khue.diverge/stepDiverge.skill.ts +149 -0
- package/dist/roles/thinker/skills/khue.diverge/stepDiverge.ts +151 -0
- package/dist/roles/thinker/skills/khue.encompose/.readme.md +7 -0
- package/dist/roles/thinker/skills/khue.instantiate/.readme.md +14 -0
- package/dist/roles/thinker/skills/khue.instantiate/stepInstantiate.skill.js +1 -1
- package/dist/roles/thinker/skills/khue.instantiate/stepInstantiate.skill.js.map +1 -1
- package/dist/roles/thinker/skills/khue.instantiate/stepInstantiate.skill.ts +190 -0
- package/dist/roles/thinker/skills/khue.instantiate/stepInstantiate.ts +132 -0
- package/dist/roles/thinker/skills/khue.triage/.demo/laughs.v2025_08_18.i1.md +29 -0
- package/dist/roles/thinker/skills/khue.triage/.demo/user.journeys.v2025_08_17.i1.md +86 -0
- package/dist/roles/thinker/skills/khue.triage/.demo/user.journeys.v2025_08_17.i2.md +68 -0
- package/dist/roles/thinker/skills/khue.triage/.readme.md +0 -0
- package/dist/roles/thinker/skills/khue.triage/stepTriage.skill.js +1 -1
- package/dist/roles/thinker/skills/khue.triage/stepTriage.skill.js.map +1 -1
- package/dist/roles/thinker/skills/khue.triage/stepTriage.skill.ts +174 -0
- package/dist/roles/thinker/skills/khue.triage/stepTriage.ts +153 -0
- package/package.json +9 -7
- package/readme.md +55 -0
|
@@ -0,0 +1,417 @@
|
|
|
1
|
+
# blueprint: claude code
|
|
2
|
+
|
|
3
|
+
## .what
|
|
4
|
+
|
|
5
|
+
claude code is anthropic's official cli-based coding assistant that implements a replic brain architecture with a single-threaded agentic loop, extensive tool suite, and subagent delegation pattern.
|
|
6
|
+
|
|
7
|
+
## .why
|
|
8
|
+
|
|
9
|
+
understanding claude code's architecture reveals how a production replic brain balances capability, safety, and user experience. it serves as the reference implementation for the concepts documented in this brief collection.
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## core agentic loop
|
|
14
|
+
|
|
15
|
+
### pseudocode
|
|
16
|
+
|
|
17
|
+
```python
|
|
18
|
+
def run_session(user_message, context):
|
|
19
|
+
# initialize context with system prompt + conversation history
|
|
20
|
+
context_window = build_context(
|
|
21
|
+
system_prompt=SYSTEM_PROMPT, # ~15k tokens
|
|
22
|
+
conversation_history=context.history,
|
|
23
|
+
user_message=user_message
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
while True:
|
|
27
|
+
# generate response from llm
|
|
28
|
+
response = llm.generate(
|
|
29
|
+
messages=context_window,
|
|
30
|
+
tools=TOOL_DEFINITIONS,
|
|
31
|
+
model="claude-sonnet-4" | "claude-opus-4"
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
# check for tool calls
|
|
35
|
+
if response.has_tool_calls:
|
|
36
|
+
for tool_call in response.tool_calls:
|
|
37
|
+
# permission check
|
|
38
|
+
if requires_approval(tool_call):
|
|
39
|
+
approval = await_user_approval(tool_call)
|
|
40
|
+
if not approval:
|
|
41
|
+
context_window.append(rejection_message(tool_call))
|
|
42
|
+
continue
|
|
43
|
+
|
|
44
|
+
# execute tool
|
|
45
|
+
result = execute_tool(tool_call)
|
|
46
|
+
|
|
47
|
+
# append result to context
|
|
48
|
+
context_window.append(tool_result_message(result))
|
|
49
|
+
|
|
50
|
+
# context management: summarize if approaching limit
|
|
51
|
+
if context_window.token_count > COMPACTION_THRESHOLD:
|
|
52
|
+
context_window = summarize_and_compact(context_window)
|
|
53
|
+
else:
|
|
54
|
+
# no tool calls = task complete or awaiting user input
|
|
55
|
+
display_response(response)
|
|
56
|
+
return response
|
|
57
|
+
|
|
58
|
+
# check for mid-task user interjection (h2A queue)
|
|
59
|
+
if has_pending_user_message():
|
|
60
|
+
inject_user_message(context_window)
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### key characteristics
|
|
64
|
+
|
|
65
|
+
| aspect | implementation |
|
|
66
|
+
|--------|----------------|
|
|
67
|
+
| loop type | single-threaded, synchronous within session |
|
|
68
|
+
| termination | llm responds without tool calls |
|
|
69
|
+
| tool parallelism | multiple tools per response allowed |
|
|
70
|
+
| user interjection | h2A queue for mid-task messages |
|
|
71
|
+
|
|
72
|
+
### sources
|
|
73
|
+
|
|
74
|
+
- [Building Effective Agents](https://www.anthropic.com/research/building-effective-agents) — agentic loop patterns
|
|
75
|
+
- [Building Agents with Claude Agent SDK](https://www.anthropic.com/engineering/building-agents-with-the-claude-agent-sdk) — sdk implementation
|
|
76
|
+
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
## context management
|
|
80
|
+
|
|
81
|
+
### strategy: auto-compaction via summarization
|
|
82
|
+
|
|
83
|
+
```
|
|
84
|
+
[context approaching 200k limit]
|
|
85
|
+
│
|
|
86
|
+
↓
|
|
87
|
+
[summarize earlier tool results + conversation]
|
|
88
|
+
│
|
|
89
|
+
↓
|
|
90
|
+
[replace verbose history with summary]
|
|
91
|
+
│
|
|
92
|
+
↓
|
|
93
|
+
[continue with fresh context headroom]
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### context budget
|
|
97
|
+
|
|
98
|
+
| component | typical size |
|
|
99
|
+
|-----------|--------------|
|
|
100
|
+
| system prompt | ~15k tokens |
|
|
101
|
+
| tool definitions | ~5k tokens |
|
|
102
|
+
| conversation history | variable |
|
|
103
|
+
| tool results | variable (truncated at 30k chars) |
|
|
104
|
+
| **total limit** | 200k tokens |
|
|
105
|
+
|
|
106
|
+
### compaction triggers
|
|
107
|
+
|
|
108
|
+
- approaching context limit
|
|
109
|
+
- automatic during long sessions
|
|
110
|
+
- explicit via context management tools
|
|
111
|
+
|
|
112
|
+
### sources
|
|
113
|
+
|
|
114
|
+
- [Claude Documentation](https://docs.anthropic.com) — 200k context window
|
|
115
|
+
- [Extended Thinking](https://www.anthropic.com/news/visible-extended-thinking) — context budget allocation
|
|
116
|
+
|
|
117
|
+
---
|
|
118
|
+
|
|
119
|
+
## tool interface
|
|
120
|
+
|
|
121
|
+
### builtin tools (~25)
|
|
122
|
+
|
|
123
|
+
| category | tools |
|
|
124
|
+
|----------|-------|
|
|
125
|
+
| filesystem | Read, Write, Edit, Glob, Grep, NotebookEdit |
|
|
126
|
+
| execution | Bash, Task, KillShell |
|
|
127
|
+
| web | WebSearch, WebFetch |
|
|
128
|
+
| planning | EnterPlanMode, ExitPlanMode |
|
|
129
|
+
| coordination | TodoWrite, AskUserQuestion |
|
|
130
|
+
| skills | Skill |
|
|
131
|
+
|
|
132
|
+
### tool definition format
|
|
133
|
+
|
|
134
|
+
```json
|
|
135
|
+
{
|
|
136
|
+
"name": "Edit",
|
|
137
|
+
"description": "Performs exact string replacements in files",
|
|
138
|
+
"parameters": {
|
|
139
|
+
"type": "object",
|
|
140
|
+
"properties": {
|
|
141
|
+
"file_path": {
|
|
142
|
+
"type": "string",
|
|
143
|
+
"description": "Absolute path to the file to modify"
|
|
144
|
+
},
|
|
145
|
+
"old_string": {
|
|
146
|
+
"type": "string",
|
|
147
|
+
"description": "The text to replace"
|
|
148
|
+
},
|
|
149
|
+
"new_string": {
|
|
150
|
+
"type": "string",
|
|
151
|
+
"description": "The replacement text"
|
|
152
|
+
},
|
|
153
|
+
"replace_all": {
|
|
154
|
+
"type": "boolean",
|
|
155
|
+
"default": false
|
|
156
|
+
}
|
|
157
|
+
},
|
|
158
|
+
"required": ["file_path", "old_string", "new_string"]
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
### permission model
|
|
164
|
+
|
|
165
|
+
| permission level | behavior |
|
|
166
|
+
|------------------|----------|
|
|
167
|
+
| pre-approved | execute without asking |
|
|
168
|
+
| requires approval | ask user before executing |
|
|
169
|
+
| blocked | refuse to execute |
|
|
170
|
+
|
|
171
|
+
### mcp extensibility
|
|
172
|
+
|
|
173
|
+
claude code supports custom tools via Model Context Protocol:
|
|
174
|
+
|
|
175
|
+
```
|
|
176
|
+
┌─────────────────┐ ┌──────────────────┐
|
|
177
|
+
│ Claude Code │────▶│ MCP Server │
|
|
178
|
+
└─────────────────┘ │ (custom tools) │
|
|
179
|
+
└──────────────────┘
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
### sources
|
|
183
|
+
|
|
184
|
+
- [Advanced Tool Use](https://www.anthropic.com/engineering/advanced-tool-use) — tool patterns
|
|
185
|
+
- [MCP Specification](https://modelcontextprotocol.io/) — protocol details
|
|
186
|
+
|
|
187
|
+
---
|
|
188
|
+
|
|
189
|
+
## subagent pattern
|
|
190
|
+
|
|
191
|
+
### subagent types
|
|
192
|
+
|
|
193
|
+
| type | purpose | context |
|
|
194
|
+
|------|---------|---------|
|
|
195
|
+
| Explore | codebase exploration | fresh, isolated |
|
|
196
|
+
| Plan | implementation planning | fresh, isolated |
|
|
197
|
+
| general-purpose | complex multi-step tasks | fresh, isolated |
|
|
198
|
+
| claude-code-guide | documentation lookup | fresh, isolated |
|
|
199
|
+
|
|
200
|
+
### delegation mechanism
|
|
201
|
+
|
|
202
|
+
```python
|
|
203
|
+
# parent agent context
|
|
204
|
+
parent_context = [current_conversation...]
|
|
205
|
+
|
|
206
|
+
# spawn subagent
|
|
207
|
+
subagent_result = Task(
|
|
208
|
+
subagent_type="Explore",
|
|
209
|
+
prompt="Find all authentication-related files",
|
|
210
|
+
model="haiku" # can use cheaper model
|
|
211
|
+
)
|
|
212
|
+
|
|
213
|
+
# result returned to parent
|
|
214
|
+
parent_context.append(subagent_result.summary)
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
### isolation benefits
|
|
218
|
+
|
|
219
|
+
- fresh context window (no pollution from parent)
|
|
220
|
+
- can use different/cheaper models
|
|
221
|
+
- parallelizable for independent tasks
|
|
222
|
+
- focused execution without distractions
|
|
223
|
+
|
|
224
|
+
### sources
|
|
225
|
+
|
|
226
|
+
- [Building Agents with Claude Agent SDK](https://www.anthropic.com/engineering/building-agents-with-the-claude-agent-sdk) — subagent patterns
|
|
227
|
+
|
|
228
|
+
---
|
|
229
|
+
|
|
230
|
+
## reasoning strategy
|
|
231
|
+
|
|
232
|
+
claude code implements a pragmatic subset of reasoning strategies from the research literature:
|
|
233
|
+
|
|
234
|
+
| strategy | implemented | mechanism |
|
|
235
|
+
|----------|-------------|-----------|
|
|
236
|
+
| implicit react | ✓ | trained behavior — reasoning interleaved with tool use |
|
|
237
|
+
| extended thinking | ✓ | api parameter — caller configures token budget |
|
|
238
|
+
| think tool | ✓ | model invokes mid-task for complex tool chains |
|
|
239
|
+
| plan mode | ✓ | system prompt — proactive planning before coding |
|
|
240
|
+
| evaluator-optimizer | ✓ partial | feedback loop with user/tests |
|
|
241
|
+
|
|
242
|
+
### primary: implicit react
|
|
243
|
+
|
|
244
|
+
claude code uses an implicit react pattern — reasoning is interleaved with tool use, but not always explicitly labeled:
|
|
245
|
+
|
|
246
|
+
```
|
|
247
|
+
[User: "Fix the failing test"]
|
|
248
|
+
|
|
249
|
+
[Assistant reasoning (implicit):
|
|
250
|
+
"I need to understand why the test is failing.
|
|
251
|
+
Let me read the test file first."]
|
|
252
|
+
|
|
253
|
+
[Tool: Read test file]
|
|
254
|
+
[Tool Result: test contents]
|
|
255
|
+
|
|
256
|
+
[Assistant reasoning (implicit):
|
|
257
|
+
"The test expects X but the function returns Y.
|
|
258
|
+
I need to check the implementation."]
|
|
259
|
+
|
|
260
|
+
[Tool: Read implementation]
|
|
261
|
+
...
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
### extended thinking integration
|
|
265
|
+
|
|
266
|
+
for complex tasks, extended thinking provides additional reasoning budget:
|
|
267
|
+
|
|
268
|
+
```
|
|
269
|
+
[Enable extended thinking: 16k tokens]
|
|
270
|
+
|
|
271
|
+
[Thinking block:
|
|
272
|
+
"This is a complex refactoring. Let me consider:
|
|
273
|
+
1. Current architecture...
|
|
274
|
+
2. Dependencies affected...
|
|
275
|
+
3. Migration strategy...
|
|
276
|
+
..."]
|
|
277
|
+
|
|
278
|
+
[Continue with plan-informed actions]
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
### strategies NOT implemented
|
|
282
|
+
|
|
283
|
+
tree-of-thoughts, self-consistency, and lats are not used — too expensive for interactive coding.
|
|
284
|
+
|
|
285
|
+
### deep dive
|
|
286
|
+
|
|
287
|
+
see [arc201.blueprint.claude-code.zoomin.reason.[article].md](./arc201.blueprint.claude-code.zoomin.reason.[article].md) for detailed analysis of:
|
|
288
|
+
- how each strategy is triggered (model behavior vs api vs system prompt)
|
|
289
|
+
- why certain strategies are excluded
|
|
290
|
+
- decision flow for strategy selection
|
|
291
|
+
|
|
292
|
+
### sources
|
|
293
|
+
|
|
294
|
+
- [The "think" Tool](https://www.anthropic.com/engineering/claude-think-tool) — explicit thinking
|
|
295
|
+
- [Extended Thinking](https://www.anthropic.com/news/visible-extended-thinking) — compute scaling
|
|
296
|
+
- [Building Effective Agents](https://www.anthropic.com/research/building-effective-agents) — pattern selection
|
|
297
|
+
|
|
298
|
+
---
|
|
299
|
+
|
|
300
|
+
## git integration
|
|
301
|
+
|
|
302
|
+
### workflow
|
|
303
|
+
|
|
304
|
+
```
|
|
305
|
+
[Code changes]
|
|
306
|
+
│
|
|
307
|
+
↓
|
|
308
|
+
[User: "commit this"]
|
|
309
|
+
│
|
|
310
|
+
↓
|
|
311
|
+
[Run git status, git diff]
|
|
312
|
+
│
|
|
313
|
+
↓
|
|
314
|
+
[Generate commit message]
|
|
315
|
+
│
|
|
316
|
+
↓
|
|
317
|
+
[git add + git commit]
|
|
318
|
+
│
|
|
319
|
+
↓
|
|
320
|
+
[Optional: git push (if requested)]
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
### guardrails
|
|
324
|
+
|
|
325
|
+
- never force push to main/master
|
|
326
|
+
- never amend pushed commits
|
|
327
|
+
- never skip hooks without explicit request
|
|
328
|
+
- commit only when explicitly asked
|
|
329
|
+
|
|
330
|
+
---
|
|
331
|
+
|
|
332
|
+
## session lifecycle
|
|
333
|
+
|
|
334
|
+
### initialization
|
|
335
|
+
|
|
336
|
+
1. load system prompt
|
|
337
|
+
2. boot configured skills/hooks
|
|
338
|
+
3. summarize prior conversation (if resuming)
|
|
339
|
+
4. ready for user input
|
|
340
|
+
|
|
341
|
+
### execution
|
|
342
|
+
|
|
343
|
+
1. receive user message
|
|
344
|
+
2. run agentic loop
|
|
345
|
+
3. tool calls → results → continue
|
|
346
|
+
4. respond when no more tools needed
|
|
347
|
+
|
|
348
|
+
### termination
|
|
349
|
+
|
|
350
|
+
- user exits
|
|
351
|
+
- context exhaustion (auto-compact first)
|
|
352
|
+
- explicit session end
|
|
353
|
+
|
|
354
|
+
---
|
|
355
|
+
|
|
356
|
+
## benchmark performance
|
|
357
|
+
|
|
358
|
+
| benchmark | score | notes |
|
|
359
|
+
|-----------|-------|-------|
|
|
360
|
+
| SWE-bench (verified) | ~49% | real github issues |
|
|
361
|
+
| HumanEval | competitive | function synthesis |
|
|
362
|
+
| practical coding | strong | subjective, tool-augmented |
|
|
363
|
+
|
|
364
|
+
### sources
|
|
365
|
+
|
|
366
|
+
- [SWE-bench Leaderboard](https://www.swebench.com/) — benchmark results
|
|
367
|
+
- [AI Coding Agents Benchmark](https://render.com/blog/ai-coding-agents-benchmark) — practical comparison
|
|
368
|
+
|
|
369
|
+
---
|
|
370
|
+
|
|
371
|
+
## architectural summary
|
|
372
|
+
|
|
373
|
+
```
|
|
374
|
+
┌────────────────────────────────────────────────────────┐
|
|
375
|
+
│ CLAUDE CODE │
|
|
376
|
+
├────────────────────────────────────────────────────────┤
|
|
377
|
+
│ ┌──────────────────────────────────────────────────┐ │
|
|
378
|
+
│ │ SYSTEM PROMPT (~15k) │ │
|
|
379
|
+
│ │ - persona, tools, constraints, examples │ │
|
|
380
|
+
│ └──────────────────────────────────────────────────┘ │
|
|
381
|
+
│ │ │
|
|
382
|
+
│ ┌──────────────────────▼──────────────────────────┐ │
|
|
383
|
+
│ │ AGENTIC LOOP │ │
|
|
384
|
+
│ │ while (has_tool_calls): │ │
|
|
385
|
+
│ │ response = llm.generate() │ │
|
|
386
|
+
│ │ for tool in response.tools: │ │
|
|
387
|
+
│ │ result = execute(tool) │ │
|
|
388
|
+
│ │ context.append(result) │ │
|
|
389
|
+
│ │ if context.full: compact() │ │
|
|
390
|
+
│ └──────────────────────────────────────────────────┘ │
|
|
391
|
+
│ │ │
|
|
392
|
+
│ ┌──────────────────────▼──────────────────────────┐ │
|
|
393
|
+
│ │ TOOL LAYER │ │
|
|
394
|
+
│ │ ┌─────────┐ ┌─────────┐ ┌─────────┐ │ │
|
|
395
|
+
│ │ │Builtin │ │ MCP │ │Subagent │ │ │
|
|
396
|
+
│ │ │ Tools │ │ Servers │ │ Task │ │ │
|
|
397
|
+
│ │ └─────────┘ └─────────┘ └─────────┘ │ │
|
|
398
|
+
│ └──────────────────────────────────────────────────┘ │
|
|
399
|
+
└────────────────────────────────────────────────────────┘
|
|
400
|
+
```
|
|
401
|
+
|
|
402
|
+
---
|
|
403
|
+
|
|
404
|
+
## concepts utilized
|
|
405
|
+
|
|
406
|
+
- [llm](./arc101.concept.llm.[article].md)
|
|
407
|
+
- [context-window](./arc104.concept.context-window.[article].md)
|
|
408
|
+
- [system-prompt](./arc105.concept.system-prompt.[article].md)
|
|
409
|
+
- [agentic-loop](./arc109.concept.agentic-loop.[article].md)
|
|
410
|
+
- [tool-definition](./arc106.concept.tool-definition.[article].md)
|
|
411
|
+
- [tool-call](./arc107.concept.tool-call.[article].md)
|
|
412
|
+
- [tool-result](./arc108.concept.tool-result.[article].md)
|
|
413
|
+
- [context-compaction](./arc116.concept.context-compaction.[article].md)
|
|
414
|
+
- [subagent](./arc117.concept.subagent.[article].md)
|
|
415
|
+
- [extended-thinking](./arc118.concept.extended-thinking.[article].md)
|
|
416
|
+
- [mcp](./arc119.concept.mcp.[article].md)
|
|
417
|
+
- [react-pattern](./arc111.concept.react-pattern.[article].md) (implicit)
|