Skip to content

Commit f0281a7

Browse files
erudenkoclaude
andcommitted
feat: Improve orchestrator context efficiency and fix Result type issues
Orchestrator improvements: - Updated code-reviewer agent with output requirements for orchestrator usage - Improved /dev command to reduce context usage by avoiding file reads - Agents now return brief summaries in messages instead of requiring file reads - Added context optimization documentation Transpiler fixes: - Fixed const block formatting in ResultTag enum (added Lparen/Rparen) - Added nil value panic checks in UnwrapOk() and UnwrapErr() - Disabled advanced helper methods temporarily (prevents nil panics) - Improved Result type safety 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 5611407 commit f0281a7

4 files changed

Lines changed: 324 additions & 35 deletions

File tree

.claude/agents/code-reviewer.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,30 @@ EOF
240240
- Writing to the specified output files
241241
- Returning a brief status confirmation
242242

243+
## Output Requirements
244+
245+
### When Used by Orchestrator (`/dev` command)
246+
247+
If your prompt contains specific OUTPUT FILES and RETURN MESSAGE requirements:
248+
249+
**Follow them EXACTLY**:
250+
1. Write full detailed review to the specified output file(s)
251+
2. Return ONLY the brief format specified (typically 2-3 lines with STATUS and counts)
252+
3. **NEVER return full review content** in your final message - only the summary
253+
254+
**Example Return Message** (when used by orchestrator):
255+
```
256+
STATUS: CHANGES_NEEDED
257+
CRITICAL: 2 | IMPORTANT: 5 | MINOR: 8
258+
Full review: ai-docs/sessions/20251117-233209/03-reviews/iteration-01/internal-review.md
259+
```
260+
261+
**Critical**: The orchestrator's context window is precious. Keep your return message brief.
262+
263+
### Standalone Usage (Direct Review)
264+
265+
When invoked directly (not by orchestrator), provide the full review in your response.
266+
243267
## Review Output Format
244268

245269
Structure your reviews as:

.claude/commands/dev.md

Lines changed: 63 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -291,11 +291,14 @@ INPUT FILES:
291291
YOUR TASK:
292292
Review all code changes. If this is a re-review, verify previous issues were fixed.
293293
294-
OUTPUT FILES:
294+
OUTPUT FILES (write full details here):
295295
- $REVIEW_ITER/internal-review.md - Detailed review with categorized issues (CRITICAL, IMPORTANT, MINOR)
296-
- $REVIEW_ITER/internal-summary.txt - Format: "STATUS: APPROVED" or "STATUS: CHANGES_NEEDED\nCRITICAL_COUNT: N\nIMPORTANT_COUNT: N"
297296
298-
Return ONLY a one-line status.
297+
RETURN MESSAGE (keep this brief - max 3 lines):
298+
Return ONLY this format:
299+
STATUS: [APPROVED or CHANGES_NEEDED]
300+
CRITICAL: N | IMPORTANT: N | MINOR: N
301+
Full review: $REVIEW_ITER/internal-review.md
299302
```
300303

301304
**For external models** (run in parallel):
@@ -326,18 +329,16 @@ YOUR TASK (PROXY MODE):
326329
4. Receive the response from the external model
327330
5. Format and write the review to the output file
328331
329-
OUTPUT FILES (you MUST write):
332+
OUTPUT FILES (write full details here):
330333
- $REVIEW_ITER/{MODEL_ID}-review.md - Complete review with:
331334
* Categorized issues (CRITICAL, IMPORTANT, MINOR)
332335
* Specific file locations and line numbers
333-
* At the END, include this summary section:
334-
---
335-
STATUS: APPROVED or CHANGES_NEEDED
336-
CRITICAL_COUNT: N
337-
IMPORTANT_COUNT: N
338-
MINOR_COUNT: N
339-
340-
Return ONLY: "Review by {MODEL_NAME} complete: {STATUS}"
336+
337+
RETURN MESSAGE (keep this brief - max 3 lines):
338+
Return ONLY this format:
339+
{MODEL_NAME} STATUS: [APPROVED or CHANGES_NEEDED]
340+
CRITICAL: N | IMPORTANT: N | MINOR: N
341+
Full review: $REVIEW_ITER/{MODEL_ID}-review.md
341342
```
342343

343344
**CRITICAL - Agent Selection and Execution**:
@@ -348,12 +349,26 @@ Return ONLY: "Review by {MODEL_NAME} complete: {STATUS}"
348349
- External reviewers receive "PROXY MODE" instruction with model ID/name
349350
- All agents (internal and external) return file paths and brief status only
350351

351-
### Step 3.4: Collect Review Status
352-
Read ONLY the summary/status from each review file (last few lines):
353-
- Extract STATUS and issue counts
352+
### Step 3.4: Collect Review Status (NO FILE READS)
353+
354+
**CRITICAL**: Do NOT read any review files. All agents returned brief summaries in their final messages.
355+
356+
Parse the agent return messages you already received:
357+
- Extract STATUS and issue counts from each agent's return message
354358
- Count approvals vs changes needed
355359

356-
Display to user: "Reviews complete: {N} approved, {M} need changes"
360+
Display to user:
361+
```
362+
Code Review Complete
363+
--------------------
364+
{N} reviewers: {M} approved, {K} need changes
365+
366+
[List each reviewer with their status from return messages]
367+
368+
Full reviews: $REVIEW_ITER/
369+
```
370+
371+
**DO NOT USE Read TOOL FOR REVIEW FILES** - you already have all status info from agent return messages.
357372

358373
### Step 3.5: Consolidate Feedback (if changes needed)
359374
If ANY review needs changes, invoke code-reviewer:
@@ -371,15 +386,18 @@ YOUR TASK:
371386
3. Identify conflicts between reviewers
372387
4. Prioritize issues by severity and frequency
373388
374-
OUTPUT FILES:
389+
OUTPUT FILES (write full details here):
375390
- $REVIEW_ITER/consolidated.md - Organized consolidated feedback with priority sections
376391
- $REVIEW_ITER/action-items.md - Numbered list of specific fixes needed (just the critical/important ones)
377-
- $REVIEW_ITER/consolidated-summary.txt - Format: "TOTAL_ISSUES: N\nCRITICAL: N\nIMPORTANT: N"
378392
379-
Return ONLY a one-sentence confirmation.
393+
RETURN MESSAGE (keep this brief - max 3 lines):
394+
Return ONLY this format:
395+
Consolidated {N} reviews: CRITICAL: N | IMPORTANT: N | MINOR: N
396+
Action items: $REVIEW_ITER/action-items.md
397+
Full consolidation: $REVIEW_ITER/consolidated.md
380398
```
381399

382-
Read and display ONLY `$REVIEW_ITER/consolidated-summary.txt`.
400+
**DO NOT READ consolidated files** - the agent already returned the summary in its message.
383401

384402
## Phase 4: Fix Loop
385403

@@ -401,14 +419,16 @@ INPUT FILES:
401419
YOUR TASK:
402420
Fix all CRITICAL and IMPORTANT issues. Do NOT break existing functionality.
403421
404-
OUTPUT FILES:
422+
OUTPUT FILES (write full details here):
405423
- $REVIEW_ITER/fixes-applied.md - List what you fixed
406-
- $REVIEW_ITER/fix-status.txt - Single line: "ALL_FIXED" or "PARTIAL: {reason}"
407424
408-
Return ONLY a brief one-line status.
425+
RETURN MESSAGE (keep this brief - max 2 lines):
426+
Return ONLY this format:
427+
Fixed {N} issues: [ALL_FIXED or PARTIAL: reason]
428+
Details: $REVIEW_ITER/fixes-applied.md
409429
```
410430

411-
Read ONLY `$REVIEW_ITER/fix-status.txt`.
431+
**DO NOT READ fixes-applied.md** - the agent already returned the status in its message.
412432

413433
### Step 4.3: Increment and Re-review
414434
Increment review iteration counter in session state.
@@ -442,15 +462,18 @@ YOUR TASK:
442462
2. Implement tests
443463
3. Run tests and capture results
444464
445-
OUTPUT FILES:
465+
OUTPUT FILES (write full details here):
446466
- $SESSION_DIR/04-testing/test-plan.md - What you're testing and why
447467
- $SESSION_DIR/04-testing/test-results.md - Detailed test output
448-
- $SESSION_DIR/04-testing/test-summary.txt - Format: "STATUS: PASS" or "STATUS: FAIL\nFAILED_TESTS: N\nTOTAL_TESTS: N"
449468
450-
Return ONLY a brief status message.
469+
RETURN MESSAGE (keep this brief - max 3 lines):
470+
Return ONLY this format:
471+
Tests: [PASS or FAIL]
472+
Results: Passed N/M tests
473+
Full details: $SESSION_DIR/04-testing/test-results.md
451474
```
452475

453-
Read ONLY `$SESSION_DIR/04-testing/test-summary.txt`.
476+
**DO NOT READ test files** - the agent already returned the summary in its message.
454477

455478
### Step 5.2: Handle Test Failures
456479
If tests fail:
@@ -463,13 +486,16 @@ INPUT FILES:
463486
- Test results: $SESSION_DIR/04-testing/test-results.md
464487
- Test plan: $SESSION_DIR/04-testing/test-plan.md
465488
466-
OUTPUT FILES:
489+
OUTPUT FILES (write full details here):
467490
- $SESSION_DIR/04-testing/fixes-iteration-{N}.md
468491
469-
Return brief status.
492+
RETURN MESSAGE (keep this brief - max 2 lines):
493+
Return ONLY this format:
494+
Fixed {N} test failures
495+
Details: $SESSION_DIR/04-testing/fixes-iteration-{N}.md
470496
```
471497

472-
2. Re-run golang-tester (update test-results and test-summary)
498+
2. Re-run golang-tester (will return updated status in message)
473499

474500
3. If still failing after 3 iterations, also run code-reviewer to check for issues introduced by fixes
475501

@@ -508,16 +534,20 @@ Ask user:
508534

509535
## Critical Rules for Orchestrator
510536

511-
1. **Never read full content**: Only read summary/status files (*.txt, *-summary.*, *.json)
537+
1. **NEVER read agent output files**: Agents return brief summaries in their final messages. Full details stay in files.
538+
- ❌ DO NOT use Read tool on: review files, test results, implementation notes
539+
- ✅ DO use Read tool for: session state, user input, plan summaries (written by orchestrator)
540+
- **Exception**: Only read files written by YOU (the orchestrator), never by agents
512541
2. **Always pass file paths**: Agents read their own inputs from files
513-
3. **Brief confirmations only**: Agents return max 3 sentence confirmations
542+
3. **Brief agent returns**: All agents MUST return max 3-line summaries in their final message
514543
4. **Update session state**: After each phase, update session-state.json
515544
5. **Use TodoWrite**: Create todos for phases, not individual agent steps
516545
6. **Parallel execution**: Run all reviews in parallel with multiple Task tool calls in a SINGLE message
517546
- Internal review: Task tool → code-reviewer agent (direct mode)
518547
- External reviews: Task tool → code-reviewer agent (PROXY MODE with model ID)
519548
- **NEVER use Bash tool for reviews** - agents handle their own tools
520549
7. **Preserve session dir**: Never delete session directory, it's the audit trail
550+
8. **Context efficiency**: Your context window is for coordination, not content. Keep agent outputs in files.
521551

522552
## TodoWrite Structure
523553

0 commit comments

Comments
 (0)