fix: rewrite agent instructions from agent perspective#60
fix: rewrite agent instructions from agent perspective#60koriyoshi2041 wants to merge 1 commit intosnarktank:mainfrom
Conversation
Fixes snarktank#47 ## Problem Agent instructions contained abstraction leaks—they assumed the agent understands the Ralph orchestration loop (iterations, outer bash loop), but each agent session has no memory of previous invocations. ## Changes - Replace 'iteration' → 'session' throughout - Add explicit 'no memory' statement at top of CLAUDE.md and prompt.md - Add clear 'Completion Criteria' section with specific step references - Improve Stop Condition to be explicit about session end - Contextualize why writing to files matters (future sessions can't read memory) ## Files Modified - AGENTS.md (12 lines) - CLAUDE.md (29 lines) - prompt.md (31 lines)
Greptile OverviewGreptile SummaryThis PR successfully refactors agent instruction files to eliminate abstraction leaks by rewriting them from the agent's perspective rather than the orchestrator's perspective. Key improvements:
Note on file naming: Confidence Score: 4/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant Orchestrator as Ralph Orchestrator
participant Agent as Fresh Agent Session
participant Files as File System
Note over Orchestrator: Loop until all stories complete
Orchestrator->>Files: Read prd.json
Orchestrator->>Agent: Spawn fresh session with instructions
Note over Agent: Session starts with NO memory
Agent->>Files: Read prd.json
Agent->>Files: Read progress.txt (check Codebase Patterns)
Agent->>Files: Read AGENTS.md/CLAUDE.md for context
Agent->>Agent: Pick highest priority story (passes: false)
Agent->>Files: Implement story (edit code files)
Agent->>Files: Run quality checks
alt Quality checks pass
Agent->>Files: Commit changes
Agent->>Files: Update prd.json (set passes: true)
Agent->>Files: Append to progress.txt with learnings
Agent->>Files: Update AGENTS.md/CLAUDE.md if patterns found
Agent->>Orchestrator: End session normally
else Quality checks fail
Agent->>Files: Fix issues
Note over Agent: Retry until checks pass
end
alt All stories complete
Agent->>Orchestrator: Return COMPLETE signal
Note over Orchestrator: Exit loop
else Stories remain
Note over Orchestrator: Spawn new session
Orchestrator->>Agent: Create new agent (clean context)
end
|
|
|
||
| You are an autonomous coding agent working on a software project. | ||
|
|
||
| **Important:** Each session starts fresh with no memory of previous sessions. Your only knowledge comes from reading files. This is why documenting learnings in `progress.txt` and `CLAUDE.md` is critical—future sessions will rely on what you write. |
There was a problem hiding this comment.
File name inconsistency: CLAUDE.md should reference AGENTS.md instead for consistency with prompt.md (which references AGENTS.md on the equivalent line)
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Prompt To Fix With AI
This is a comment left during a code review.
Path: CLAUDE.md
Line: 5:5
Comment:
File name inconsistency: `CLAUDE.md` should reference `AGENTS.md` instead for consistency with `prompt.md` (which references `AGENTS.md` on the equivalent line)
<sub>Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!</sub>
How can I resolve this? If you propose a fix, please make it concise.|
|
||
| You are an autonomous coding agent working on a software project. | ||
|
|
||
| **Important:** Each session starts fresh with no memory of previous sessions. Your only knowledge comes from reading files. This is why documenting learnings in `progress.txt` and `CLAUDE.md` is critical—future sessions will rely on what you write. |
There was a problem hiding this comment.
Consider whether Claude Code agents should document learnings in AGENTS.md (to match prompt.md:5) instead of CLAUDE.md for cross-tool consistency
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Prompt To Fix With AI
This is a comment left during a code review.
Path: CLAUDE.md
Line: 5:5
Comment:
Consider whether Claude Code agents should document learnings in `AGENTS.md` (to match `prompt.md:5`) instead of `CLAUDE.md` for cross-tool consistency
<sub>Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!</sub>
How can I resolve this? If you propose a fix, please make it concise.|
Intentional design: |
|
Does this have any meaningful change in the results or is being overly pedantic? What evals do you have that show improvement a to what degree? Or is this all a hunch? |
Summary
Fixes #47
Agent instructions contained abstraction leaks—they were written from the orchestrator's perspective, assuming the agent understands the Ralph loop. But each agent session starts fresh with no memory of previous invocations.
Changes
1. Terminology:
iteration→sessionThe word "iteration" implies knowledge of an outer loop. Changed to "session" which makes sense from the agent's POV.
2. Explicit Memory Statement
Added at the top of CLAUDE.md and prompt.md:
3. Completion Criteria Section
Added explicit criteria referencing specific step numbers (5, 6, 8, 9, 10) so the agent knows exactly when its work is done.
4. Improved Stop Condition
Before (vague):
After (explicit):
5. Contextualized File Writing
Explained why writing to files matters—future sessions have no memory, only files.
Files Modified
AGENTS.md(12 lines)CLAUDE.md(29 lines)prompt.md(31 lines)Testing
The agent no longer needs to understand orchestration concepts—it only needs to follow the numbered steps and check the explicit completion criteria.