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,507 @@
|
|
|
1
|
+
# blueprint: claude code — reasoning strategies (zoom-in)
|
|
2
|
+
|
|
3
|
+
## .what
|
|
4
|
+
|
|
5
|
+
a detailed analysis of how claude code leverages reasoning strategies from the research literature, mapping theoretical patterns to production implementation choices.
|
|
6
|
+
|
|
7
|
+
## .why
|
|
8
|
+
|
|
9
|
+
understanding which reasoning strategies claude code uses (and doesn't use) reveals the tradeoffs between theoretical power and practical constraints like latency, cost, and user experience. this zoom-in connects the atomic concepts to their concrete implementation.
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## reasoning strategy landscape
|
|
14
|
+
|
|
15
|
+
the research literature offers many reasoning strategies. claude code implements a pragmatic subset:
|
|
16
|
+
|
|
17
|
+
| strategy | implemented? | how |
|
|
18
|
+
|----------|--------------|-----|
|
|
19
|
+
| react (implicit) | ✓ yes | interleaved reasoning + tool use |
|
|
20
|
+
| extended thinking | ✓ yes | configurable token budget |
|
|
21
|
+
| think tool | ✓ yes | explicit mid-task reasoning pause |
|
|
22
|
+
| plan-and-solve | ✓ yes | plan mode + EnterPlanMode tool |
|
|
23
|
+
| evaluator-optimizer | ✓ partial | feedback loop with user/tests |
|
|
24
|
+
| reflexion | ✗ not explicit | user feedback serves similar role |
|
|
25
|
+
| tree-of-thoughts | ✗ no | too expensive for interactive use |
|
|
26
|
+
| self-consistency | ✗ no | single path, no voting |
|
|
27
|
+
| lats | ✗ no | no monte carlo tree search |
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## implemented strategies
|
|
32
|
+
|
|
33
|
+
### 1. implicit react
|
|
34
|
+
|
|
35
|
+
claude code's core loop is fundamentally react-shaped:
|
|
36
|
+
|
|
37
|
+
```
|
|
38
|
+
[Thought] "I need to understand why the test is failing"
|
|
39
|
+
[Action] Read test file
|
|
40
|
+
[Observe] test contents
|
|
41
|
+
[Thought] "The test expects X but function returns Y"
|
|
42
|
+
[Action] Read implementation
|
|
43
|
+
[Observe] function code
|
|
44
|
+
[Thought] "I see the bug — missing null check"
|
|
45
|
+
[Action] Edit file
|
|
46
|
+
...
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
**key difference from paper**: reasoning traces are implicit (not labeled `Thought:`/`Action:`). the model reasons naturally in its response, then calls tools.
|
|
50
|
+
|
|
51
|
+
**why implicit**: explicit labels add token overhead and feel mechanical. implicit react preserves conversational flow while maintaining the grounding benefits.
|
|
52
|
+
|
|
53
|
+
### sources
|
|
54
|
+
|
|
55
|
+
- [ReAct: Synergizing Reasoning and Acting](https://arxiv.org/abs/2210.03629) — original pattern
|
|
56
|
+
- [Building Effective Agents](https://www.anthropic.com/research/building-effective-agents) — anthropic's approach
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
### 2. extended thinking
|
|
61
|
+
|
|
62
|
+
extended thinking allocates a dedicated token budget for reasoning *before* response generation:
|
|
63
|
+
|
|
64
|
+
```
|
|
65
|
+
┌─────────────────────────────────────────────────┐
|
|
66
|
+
│ EXTENDED THINKING │
|
|
67
|
+
│ budget: 16k tokens │
|
|
68
|
+
│ │
|
|
69
|
+
│ "This refactoring is complex. Let me consider: │
|
|
70
|
+
│ 1. Current architecture patterns... │
|
|
71
|
+
│ 2. Which files will be affected... │
|
|
72
|
+
│ 3. Migration strategy options... │
|
|
73
|
+
│ 4. Risk of breaking changes..." │
|
|
74
|
+
└─────────────────────────────────────────────────┘
|
|
75
|
+
│
|
|
76
|
+
↓
|
|
77
|
+
┌─────────────────────────────────────────────────┐
|
|
78
|
+
│ RESPONSE (informed by thinking) │
|
|
79
|
+
│ "I'll refactor in three phases: ..." │
|
|
80
|
+
└─────────────────────────────────────────────────┘
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
**when it helps**: complex coding, math, multi-file refactoring, architectural decisions.
|
|
84
|
+
|
|
85
|
+
**budget guidelines**:
|
|
86
|
+
|
|
87
|
+
| budget | suitable for |
|
|
88
|
+
|--------|--------------|
|
|
89
|
+
| 1k-4k | simple analysis |
|
|
90
|
+
| 4k-16k | moderate complexity |
|
|
91
|
+
| 16k-64k | complex coding/math |
|
|
92
|
+
| 64k-128k | deep research |
|
|
93
|
+
|
|
94
|
+
**interleaved thinking** (claude 4+): with the `interleaved-thinking-2025-05-14` beta header, claude can think *between* tool calls, not just before the first response.
|
|
95
|
+
|
|
96
|
+
### sources
|
|
97
|
+
|
|
98
|
+
- [Claude's Extended Thinking](https://www.anthropic.com/news/visible-extended-thinking) — announcement
|
|
99
|
+
- [Building with Extended Thinking](https://docs.claude.com/en/docs/build-with-claude/extended-thinking) — implementation guide
|
|
100
|
+
- [Extended Thinking Tips](https://platform.claude.com/docs/en/build-with-claude/prompt-engineering/extended-thinking-tips) — best practices
|
|
101
|
+
|
|
102
|
+
---
|
|
103
|
+
|
|
104
|
+
### 3. think tool
|
|
105
|
+
|
|
106
|
+
the think tool is a *tool* claude can call mid-task to pause and reason:
|
|
107
|
+
|
|
108
|
+
```python
|
|
109
|
+
{
|
|
110
|
+
"name": "think",
|
|
111
|
+
"description": "Record reasoning during complex tasks. Does not
|
|
112
|
+
obtain new information or change state."
|
|
113
|
+
}
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
**vs extended thinking**:
|
|
117
|
+
|
|
118
|
+
| aspect | extended thinking | think tool |
|
|
119
|
+
|--------|-------------------|------------|
|
|
120
|
+
| when | before first response | during response, between tool calls |
|
|
121
|
+
| purpose | deep planning | process new information |
|
|
122
|
+
| trigger | api parameter | claude decides to call it |
|
|
123
|
+
| visibility | may be hidden | logged in conversation |
|
|
124
|
+
|
|
125
|
+
**when think tool excels**:
|
|
126
|
+
- long chains of tool calls needing intermediate reasoning
|
|
127
|
+
- processing complex tool results before next action
|
|
128
|
+
- policy-heavy environments with detailed guidelines
|
|
129
|
+
- sequential decisions where each step builds on previous
|
|
130
|
+
|
|
131
|
+
**performance impact**: +54% on complex customer service scenarios (tau-bench), +1.6% on SWE-bench.
|
|
132
|
+
|
|
133
|
+
### sources
|
|
134
|
+
|
|
135
|
+
- [The "think" Tool: Enabling Claude to Stop and Think](https://www.anthropic.com/engineering/claude-think-tool) — official guide
|
|
136
|
+
- [Anthropic's new 'think tool'](https://the-decoder.com/anthropics-new-think-tool-lets-claude-take-notes-to-solve-complex-problems/) — analysis
|
|
137
|
+
|
|
138
|
+
---
|
|
139
|
+
|
|
140
|
+
### 4. plan mode (plan-and-solve)
|
|
141
|
+
|
|
142
|
+
plan mode implements the plan-and-solve pattern as a first-class workflow:
|
|
143
|
+
|
|
144
|
+
```
|
|
145
|
+
┌─────────────────────────────────────────────────┐
|
|
146
|
+
│ PLAN MODE │
|
|
147
|
+
│ (shift+tab twice to enter) │
|
|
148
|
+
│ │
|
|
149
|
+
│ ┌───────────────────────────────────────────┐ │
|
|
150
|
+
│ │ 1. READ: explore codebase (read-only) │ │
|
|
151
|
+
│ │ 2. ANALYZE: understand patterns │ │
|
|
152
|
+
│ │ 3. PLAN: write markdown implementation │ │
|
|
153
|
+
│ │ plan to .claude/plans/ │ │
|
|
154
|
+
│ │ 4. PRESENT: call ExitPlanMode for review │ │
|
|
155
|
+
│ └───────────────────────────────────────────┘ │
|
|
156
|
+
│ │
|
|
157
|
+
│ [NO file writes, NO bash execution] │
|
|
158
|
+
└─────────────────────────────────────────────────┘
|
|
159
|
+
│
|
|
160
|
+
user approves
|
|
161
|
+
│
|
|
162
|
+
↓
|
|
163
|
+
┌─────────────────────────────────────────────────┐
|
|
164
|
+
│ EXECUTION MODE │
|
|
165
|
+
│ - execute plan step by step │
|
|
166
|
+
│ - user can interrupt at any time │
|
|
167
|
+
└─────────────────────────────────────────────────┘
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
**architectural insight**: plans are stored as markdown files in `.claude/plans/`, creating an audit trail of architectural decisions that outlives sessions.
|
|
171
|
+
|
|
172
|
+
**why it works**: mirrors how experienced engineers work — read, understand, plan, *then* build. prevents premature coding and reduces rework.
|
|
173
|
+
|
|
174
|
+
**plan mode benefits**:
|
|
175
|
+
- faster iteration (read-only is cheap)
|
|
176
|
+
- token-efficient (opus shines in planning)
|
|
177
|
+
- reviewable artifacts (plans are diffable)
|
|
178
|
+
- reversible (no changes until approved)
|
|
179
|
+
|
|
180
|
+
### sources
|
|
181
|
+
|
|
182
|
+
- [Understanding Claude Code Plan Mode](https://lord.technology/2025/07/03/understanding-claude-code-plan-mode-and-the-architecture-of-intent.html) — deep dive
|
|
183
|
+
- [What Actually Is Claude Code's Plan Mode?](https://lucumr.pocoo.org/2025/12/17/what-is-plan-mode/) — armin ronacher's analysis
|
|
184
|
+
- [Plan-and-Solve Prompting](https://arxiv.org/abs/2305.04091) — original research
|
|
185
|
+
|
|
186
|
+
---
|
|
187
|
+
|
|
188
|
+
### 5. evaluator-optimizer loop
|
|
189
|
+
|
|
190
|
+
claude code implements a natural evaluator-optimizer pattern through its feedback loop:
|
|
191
|
+
|
|
192
|
+
```
|
|
193
|
+
┌─────────┐ ┌─────────┐ ┌─────────┐
|
|
194
|
+
│ GATHER │────▶│ ACT │────▶│ VERIFY │
|
|
195
|
+
│ CONTEXT │ │ │ │ │
|
|
196
|
+
└─────────┘ └─────────┘ └─────────┘
|
|
197
|
+
▲ │
|
|
198
|
+
│ │
|
|
199
|
+
└───────────────────────────────┘
|
|
200
|
+
(if not satisfied)
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
**forms of verification**:
|
|
204
|
+
- run tests after code changes
|
|
205
|
+
- check build output
|
|
206
|
+
- user approval for risky operations
|
|
207
|
+
- self-verification via file re-reading
|
|
208
|
+
|
|
209
|
+
**not formal reflexion**: claude code doesn't maintain an explicit "reflection memory" across attempts. however, the iterative loop with test feedback serves a similar function — failures inform subsequent attempts within the same session.
|
|
210
|
+
|
|
211
|
+
### sources
|
|
212
|
+
|
|
213
|
+
- [Building Agents with the Claude Agent SDK](https://www.anthropic.com/engineering/building-agents-with-the-claude-agent-sdk) — feedback loop pattern
|
|
214
|
+
|
|
215
|
+
---
|
|
216
|
+
|
|
217
|
+
## strategies NOT implemented
|
|
218
|
+
|
|
219
|
+
### tree of thoughts
|
|
220
|
+
|
|
221
|
+
**why not**: ToT requires multiple LLM calls per step (generate candidates → evaluate each → select best). for interactive coding, this adds unacceptable latency. a single ToT "step" might require 5-10 LLM calls.
|
|
222
|
+
|
|
223
|
+
**alternative**: extended thinking provides some deliberation benefits without the call overhead.
|
|
224
|
+
|
|
225
|
+
### self-consistency
|
|
226
|
+
|
|
227
|
+
**why not**: SC samples multiple reasoning paths and votes on the answer. this multiplies cost by the number of samples (typically 5-40x).
|
|
228
|
+
|
|
229
|
+
**alternative**: extended thinking allows exploring multiple approaches within a single forward pass.
|
|
230
|
+
|
|
231
|
+
### lats (language agent tree search)
|
|
232
|
+
|
|
233
|
+
**why not**: LATS combines tree search with monte carlo methods, requiring many rollouts. prohibitively expensive for real-time interaction.
|
|
234
|
+
|
|
235
|
+
**alternative**: subagents can explore different approaches in parallel, with human selecting the best result.
|
|
236
|
+
|
|
237
|
+
### formal reflexion
|
|
238
|
+
|
|
239
|
+
**why not**: reflexion requires explicit episodic memory of past failures. claude code sessions are typically short enough that context window serves as implicit memory.
|
|
240
|
+
|
|
241
|
+
**alternative**: user feedback serves the "evaluator" role. test failures inform next attempt.
|
|
242
|
+
|
|
243
|
+
---
|
|
244
|
+
|
|
245
|
+
## how strategies are triggered
|
|
246
|
+
|
|
247
|
+
a key architectural question: where does each reasoning strategy live?
|
|
248
|
+
|
|
249
|
+
| strategy | trigger mechanism | location |
|
|
250
|
+
|----------|-------------------|----------|
|
|
251
|
+
| implicit react | always on | baked into model weights |
|
|
252
|
+
| extended thinking | api parameter | caller configures budget |
|
|
253
|
+
| think tool | model decides | system prompt instructs when to use |
|
|
254
|
+
| plan mode | user or model | system prompt + EnterPlanMode tool |
|
|
255
|
+
| subagent types | model decides | system prompt defines types + when to use |
|
|
256
|
+
|
|
257
|
+
---
|
|
258
|
+
|
|
259
|
+
## what's trained into model weights
|
|
260
|
+
|
|
261
|
+
these capabilities exist in the model regardless of system prompt:
|
|
262
|
+
|
|
263
|
+
| capability | how it's trained | evidence |
|
|
264
|
+
|------------|------------------|----------|
|
|
265
|
+
| **chain-of-thought reasoning** | constitutional AI + RLHF | model reasons step-by-step without prompting |
|
|
266
|
+
| **implicit react** | RLHF with tool use examples | naturally interleaves reasoning with tool calls |
|
|
267
|
+
| **tool call formatting** | fine-tuning on function calling | knows JSON schema format without examples |
|
|
268
|
+
| **instruction following** | RLHF | follows instructions without few-shot examples |
|
|
269
|
+
| **coding ability** | pre-training + RLHF | writes code across languages |
|
|
270
|
+
| **constitutional values** | constitutional AI (RLAIF) | helpful, harmless, honest without prompting |
|
|
271
|
+
|
|
272
|
+
### constitutional AI training
|
|
273
|
+
|
|
274
|
+
anthropic's constitutional AI process:
|
|
275
|
+
|
|
276
|
+
1. **supervised phase**: model generates responses → self-critiques against principles → revises → fine-tuned on revisions
|
|
277
|
+
2. **RLAIF phase**: AI compares response pairs against constitution → preference model trained → model fine-tuned via RL
|
|
278
|
+
|
|
279
|
+
this embeds values and reasoning patterns into weights, not just prompts.
|
|
280
|
+
|
|
281
|
+
### implicit react is trained behavior
|
|
282
|
+
|
|
283
|
+
**implicit react** is inherent to how claude reasons. no system prompt needed — the model naturally interleaves reasoning with tool calls. this emerged from:
|
|
284
|
+
|
|
285
|
+
- RLHF training on agentic tasks
|
|
286
|
+
- exposure to tool use during training
|
|
287
|
+
- reward for grounded reasoning (reasoning that references observations)
|
|
288
|
+
|
|
289
|
+
### sources
|
|
290
|
+
|
|
291
|
+
- [Constitutional AI: Harmlessness from AI Feedback](https://www.anthropic.com/research/constitutional-ai-harmlessness-from-ai-feedback) — training method
|
|
292
|
+
- [Tool Use Now Generally Available](https://www.maginative.com/article/tool-use-now-generally-available-in-anthropics-claude-ai/) — function calling
|
|
293
|
+
|
|
294
|
+
---
|
|
295
|
+
|
|
296
|
+
## what's configured by api caller (not in system prompt)
|
|
297
|
+
|
|
298
|
+
these are set by the application calling the API, invisible to the system prompt:
|
|
299
|
+
|
|
300
|
+
| parameter | effect | who controls |
|
|
301
|
+
|-----------|--------|--------------|
|
|
302
|
+
| `thinking.budget_tokens` | extended thinking token limit | application developer |
|
|
303
|
+
| `model` | which claude model to use | application developer |
|
|
304
|
+
| `max_tokens` | response length limit | application developer |
|
|
305
|
+
| `tools` | available tool definitions | application developer |
|
|
306
|
+
|
|
307
|
+
**extended thinking** specifically is NOT in the system prompt — it's an API parameter:
|
|
308
|
+
|
|
309
|
+
```python
|
|
310
|
+
response = client.messages.create(
|
|
311
|
+
model="claude-opus-4-5-20250101",
|
|
312
|
+
thinking={
|
|
313
|
+
"type": "enabled",
|
|
314
|
+
"budget_tokens": 16000 # caller sets budget
|
|
315
|
+
},
|
|
316
|
+
...
|
|
317
|
+
)
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
the caller decides the budget. higher budget = more thinking = higher cost + latency.
|
|
321
|
+
|
|
322
|
+
---
|
|
323
|
+
|
|
324
|
+
## what's instructed via system prompt
|
|
325
|
+
|
|
326
|
+
**plan mode** is heavily prompted in the system prompt:
|
|
327
|
+
|
|
328
|
+
```
|
|
329
|
+
## EnterPlanMode tool
|
|
330
|
+
Use this tool proactively when you're about to start a
|
|
331
|
+
non-trivial implementation task. Getting user sign-off
|
|
332
|
+
on your approach before writing code prevents wasted
|
|
333
|
+
effort and ensures alignment.
|
|
334
|
+
|
|
335
|
+
When to Use:
|
|
336
|
+
1. New Feature Implementation
|
|
337
|
+
2. Multiple Valid Approaches
|
|
338
|
+
3. Code Modifications affecting existing behavior
|
|
339
|
+
4. Architectural Decisions
|
|
340
|
+
...
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
the system prompt explicitly tells claude *when* to use plan mode proactively, not just when asked.
|
|
344
|
+
|
|
345
|
+
**subagent delegation** is similarly prompted:
|
|
346
|
+
|
|
347
|
+
```
|
|
348
|
+
## Task tool
|
|
349
|
+
Use this tool when the task matches the agent's description.
|
|
350
|
+
You should proactively use the Task tool with specialized
|
|
351
|
+
agents when the task at hand matches the agent's description.
|
|
352
|
+
|
|
353
|
+
Available agent types:
|
|
354
|
+
- Explore: Fast agent for codebase exploration
|
|
355
|
+
- Plan: Software architect agent for designing plans
|
|
356
|
+
- general-purpose: Multi-step tasks
|
|
357
|
+
...
|
|
358
|
+
```
|
|
359
|
+
|
|
360
|
+
### model autonomy
|
|
361
|
+
|
|
362
|
+
critically, the system prompt gives claude *judgment* about when to apply these strategies:
|
|
363
|
+
|
|
364
|
+
```
|
|
365
|
+
"if unsure whether to use [plan mode], err on the side of
|
|
366
|
+
planning — it's better to get alignment upfront than to
|
|
367
|
+
redo work"
|
|
368
|
+
```
|
|
369
|
+
|
|
370
|
+
so the model decides based on task complexity, not just user request.
|
|
371
|
+
|
|
372
|
+
---
|
|
373
|
+
|
|
374
|
+
## summary: three layers of reasoning control
|
|
375
|
+
|
|
376
|
+
```
|
|
377
|
+
┌─────────────────────────────────────────────────────────────────┐
|
|
378
|
+
│ LAYER 1: MODEL WEIGHTS (trained, always present) │
|
|
379
|
+
├─────────────────────────────────────────────────────────────────┤
|
|
380
|
+
│ • chain-of-thought reasoning │
|
|
381
|
+
│ • implicit react (interleaved reasoning + tool calls) │
|
|
382
|
+
│ • tool call formatting (JSON schema) │
|
|
383
|
+
│ • constitutional values (helpful, harmless, honest) │
|
|
384
|
+
│ • instruction following │
|
|
385
|
+
│ • coding ability │
|
|
386
|
+
└─────────────────────────────────────────────────────────────────┘
|
|
387
|
+
│
|
|
388
|
+
▼
|
|
389
|
+
┌─────────────────────────────────────────────────────────────────┐
|
|
390
|
+
│ LAYER 2: API PARAMETERS (caller configures) │
|
|
391
|
+
├─────────────────────────────────────────────────────────────────┤
|
|
392
|
+
│ • extended thinking budget (thinking.budget_tokens) │
|
|
393
|
+
│ • model selection (claude-opus-4, claude-sonnet-4) │
|
|
394
|
+
│ • available tools (tool definitions) │
|
|
395
|
+
│ • max tokens, temperature, etc. │
|
|
396
|
+
└─────────────────────────────────────────────────────────────────┘
|
|
397
|
+
│
|
|
398
|
+
▼
|
|
399
|
+
┌─────────────────────────────────────────────────────────────────┐
|
|
400
|
+
│ LAYER 3: SYSTEM PROMPT (anthropic configures for claude code) │
|
|
401
|
+
├─────────────────────────────────────────────────────────────────┤
|
|
402
|
+
│ • when to use plan mode (criteria + proactive guidance) │
|
|
403
|
+
│ • when to use subagents (types + selection heuristics) │
|
|
404
|
+
│ • when to use think tool (complex chains guidance) │
|
|
405
|
+
│ • specific tool usage instructions │
|
|
406
|
+
│ • behavioral constraints (git safety, permission model) │
|
|
407
|
+
└─────────────────────────────────────────────────────────────────┘
|
|
408
|
+
```
|
|
409
|
+
|
|
410
|
+
**key insight**: the reasoning strategy is a product of all three layers. claude code's effectiveness comes from carefully orchestrating trained capabilities (layer 1) with appropriate compute budget (layer 2) and specific behavioral guidance (layer 3).
|
|
411
|
+
|
|
412
|
+
---
|
|
413
|
+
|
|
414
|
+
## strategy selection heuristic
|
|
415
|
+
|
|
416
|
+
claude code dynamically applies reasoning strategies based on task complexity:
|
|
417
|
+
|
|
418
|
+
```
|
|
419
|
+
[Simple task]
|
|
420
|
+
└─▶ implicit react only
|
|
421
|
+
|
|
422
|
+
[Moderate complexity]
|
|
423
|
+
└─▶ implicit react + extended thinking (if budget configured)
|
|
424
|
+
|
|
425
|
+
[High complexity / new feature]
|
|
426
|
+
└─▶ plan mode → approval → execution with think tool
|
|
427
|
+
|
|
428
|
+
[Long tool chains]
|
|
429
|
+
└─▶ think tool between critical steps
|
|
430
|
+
|
|
431
|
+
[Multi-concern task]
|
|
432
|
+
└─▶ subagent delegation (explore, plan, execute separately)
|
|
433
|
+
```
|
|
434
|
+
|
|
435
|
+
### decision flow
|
|
436
|
+
|
|
437
|
+
```
|
|
438
|
+
┌─────────────────────────────────────────────────┐
|
|
439
|
+
│ USER REQUEST │
|
|
440
|
+
└─────────────────────────────────────────────────┘
|
|
441
|
+
│
|
|
442
|
+
▼
|
|
443
|
+
┌─────────────────────────────────────────────────┐
|
|
444
|
+
│ Is this non-trivial implementation? │
|
|
445
|
+
│ (system prompt criteria) │
|
|
446
|
+
├─────────────────────────────────────────────────┤
|
|
447
|
+
│ YES → EnterPlanMode (proactive) │
|
|
448
|
+
│ NO → proceed with implicit react │
|
|
449
|
+
└─────────────────────────────────────────────────┘
|
|
450
|
+
│
|
|
451
|
+
▼
|
|
452
|
+
┌─────────────────────────────────────────────────┐
|
|
453
|
+
│ Does this need codebase exploration? │
|
|
454
|
+
├─────────────────────────────────────────────────┤
|
|
455
|
+
│ YES → Task(subagent_type="Explore") │
|
|
456
|
+
│ NO → continue in main context │
|
|
457
|
+
└─────────────────────────────────────────────────┘
|
|
458
|
+
│
|
|
459
|
+
▼
|
|
460
|
+
┌─────────────────────────────────────────────────┐
|
|
461
|
+
│ [Execute with implicit react] │
|
|
462
|
+
│ - if extended thinking enabled by caller: │
|
|
463
|
+
│ use budget for complex reasoning │
|
|
464
|
+
│ - if long tool chain: │
|
|
465
|
+
│ model may invoke think tool │
|
|
466
|
+
└─────────────────────────────────────────────────┘
|
|
467
|
+
```
|
|
468
|
+
|
|
469
|
+
---
|
|
470
|
+
|
|
471
|
+
## architectural insight
|
|
472
|
+
|
|
473
|
+
claude code's reasoning architecture reflects a key insight from the research:
|
|
474
|
+
|
|
475
|
+
> **simple patterns, well-orchestrated, outperform complex patterns poorly executed.**
|
|
476
|
+
|
|
477
|
+
rather than implementing sophisticated techniques like ToT or LATS, claude code focuses on:
|
|
478
|
+
|
|
479
|
+
1. **implicit react** — grounded reasoning at every step
|
|
480
|
+
2. **extended thinking** — more compute when needed
|
|
481
|
+
3. **plan mode** — explicit separation of concerns
|
|
482
|
+
4. **think tool** — targeted reasoning mid-task
|
|
483
|
+
5. **human-in-the-loop** — user as evaluator/optimizer
|
|
484
|
+
|
|
485
|
+
this pragmatic approach achieves ~49% on SWE-bench verified while maintaining interactive response times.
|
|
486
|
+
|
|
487
|
+
---
|
|
488
|
+
|
|
489
|
+
## related concepts
|
|
490
|
+
|
|
491
|
+
- [react-pattern](./arc111.concept.react-pattern.[article].md)
|
|
492
|
+
- [extended-thinking](./arc118.concept.extended-thinking.[article].md)
|
|
493
|
+
- [plan-and-solve](./arc122.concept.plan-and-solve.[article].md)
|
|
494
|
+
- [reflexion-pattern](./arc112.concept.reflexion-pattern.[article].md)
|
|
495
|
+
- [tree-of-thoughts](./arc113.concept.tree-of-thoughts.[article].md)
|
|
496
|
+
- [agentic-loop](./arc109.concept.agentic-loop.[article].md)
|
|
497
|
+
|
|
498
|
+
---
|
|
499
|
+
|
|
500
|
+
## sources
|
|
501
|
+
|
|
502
|
+
- [Building Effective Agents](https://www.anthropic.com/research/building-effective-agents) — foundational patterns
|
|
503
|
+
- [The "think" Tool](https://www.anthropic.com/engineering/claude-think-tool) — think tool guide
|
|
504
|
+
- [Claude's Extended Thinking](https://www.anthropic.com/news/visible-extended-thinking) — extended thinking
|
|
505
|
+
- [Building Agents with Claude Agent SDK](https://www.anthropic.com/engineering/building-agents-with-the-claude-agent-sdk) — SDK patterns
|
|
506
|
+
- [Understanding Claude Code Plan Mode](https://lord.technology/2025/07/03/understanding-claude-code-plan-mode-and-the-architecture-of-intent.html) — plan mode analysis
|
|
507
|
+
- [What Actually Is Claude Code's Plan Mode?](https://lucumr.pocoo.org/2025/12/17/what-is-plan-mode/) — plan mode deep dive
|