Skip to content

Commit 9993247

Browse files
committed
refactor: clean up /init command to properly handle existing AGENTS.md files
- Consolidate all AGENTS.md path checking into step 1 with CRITICAL emphasis - Add explicit instructions for deep dive improvement of existing files - Remove redundant mentions throughout the workflow - Emphasize iterating and enhancing existing files, not just appending - Add clear guidance on cleaning up outdated info and reorganizing - Make discovery phase the single source of truth for file checking
1 parent 1a46dc9 commit 9993247

File tree

1 file changed

+66
-34
lines changed

1 file changed

+66
-34
lines changed

src/services/command/built-in-commands.ts

Lines changed: 66 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,23 @@ Please analyze this codebase and create an AGENTS.md file containing:
3939
<todo_list_creation>
4040
If the update_todo_list tool is available, create a todo list with these focused analysis steps:
4141
42-
1. Quick scan for existing docs
43-
- AI assistant rules (.cursorrules, CLAUDE.md, AGENTS.md, .roorules)
44-
- Check for existing AGENTS.md in root directory
45-
- Check for existing AGENTS.md in .roo/rules-code/, .roo/rules-debug/, .roo/rules-ask/, .roo/rules-architect/
46-
- README and key documentation
42+
1. Check for existing AGENTS.md files
43+
CRITICAL - Check these EXACT paths:
44+
- ./AGENTS.md (root directory)
45+
- ./.roo/rules-code/AGENTS.md
46+
- ./.roo/rules-debug/AGENTS.md
47+
- ./.roo/rules-ask/AGENTS.md
48+
- ./.roo/rules-architect/AGENTS.md
49+
50+
If ANY of these exist:
51+
- Read them thoroughly
52+
- Analyze what's already documented
53+
- Plan improvements: what to add, update, or clean up
54+
- Focus on iterating and enhancing, not replacing
55+
56+
Also check for other AI assistant rules:
57+
- .cursorrules, CLAUDE.md, .roorules
58+
- .cursor/rules/, .github/copilot-instructions.md
4759
4860
2. Identify stack
4961
- Language, framework, build tools
@@ -70,16 +82,14 @@ Please analyze this codebase and create an AGENTS.md file containing:
7082
- Framework and run commands
7183
- Directory requirements
7284
73-
8. Compile concise AGENTS.md
74-
- Essential sections only
75-
- Brief, scannable format
76-
- Project-specific focus
77-
78-
9. Create mode-specific rule directories
79-
- Create directory structures for the four core modes: .roo/rules-code/, .roo/rules-ask/, .roo/rules-architect/, .roo/rules-debug/
80-
- Create mode-specific AGENTS.md files with rules specific to that mode's purpose and capabilities
81-
- These rules should provide additive context and not just repeat the mode definitions
82-
- Only include rules that you have high confidence are accurate, valuable, and non-obvious
85+
8. Compile/Update AGENTS.md files
86+
- If files exist: Deep dive into improving them
87+
* Clean up outdated information
88+
* Add newly discovered non-obvious patterns
89+
* Reorganize for better clarity
90+
* Ensure consistency across all files
91+
- If creating new: Follow the non-obvious-only principle
92+
- Create mode-specific files in .roo/rules-*/ directories
8393
8494
Note: If update_todo_list is not available, proceed with the analysis workflow directly without creating a todo list.
8595
</todo_list_creation>
@@ -88,10 +98,22 @@ Please analyze this codebase and create an AGENTS.md file containing:
8898
<analysis_workflow>
8999
Follow the comprehensive analysis workflow to:
90100
91-
1. **Discovery Phase**: Find existing documentation and AI assistant rules
92-
- Check for existing AGENTS.md in root directory
93-
- Check for existing AGENTS.md files in .roo/rules-*/ directories
94-
- If found, read and improve them rather than replacing
101+
1. **Discovery Phase**:
102+
CRITICAL - First check for existing AGENTS.md files at these EXACT locations:
103+
- ./AGENTS.md (root)
104+
- ./.roo/rules-code/AGENTS.md
105+
- ./.roo/rules-debug/AGENTS.md
106+
- ./.roo/rules-ask/AGENTS.md
107+
- ./.roo/rules-architect/AGENTS.md
108+
109+
If found, perform deep analysis:
110+
- What information is already captured?
111+
- What's outdated or incorrect?
112+
- What non-obvious patterns are missing?
113+
- How can the organization be improved?
114+
115+
Also find other AI assistant rules and documentation
116+
95117
2. **Project Identification**: Identify language, stack, and build system
96118
3. **Command Extraction**: Extract and verify essential commands
97119
4. **Architecture Mapping**: Create visual flow diagrams of core processes
@@ -105,8 +127,16 @@ Please analyze this codebase and create an AGENTS.md file containing:
105127
106128
<output_structure>
107129
<main_file>
108-
Create or update AGENTS.md with ONLY non-obvious information:
109-
- If AGENTS.md exists, read it first and improve/update it
130+
Create or deeply improve AGENTS.md with ONLY non-obvious information:
131+
132+
If AGENTS.md exists:
133+
- Perform thorough review and enhancement
134+
- Clean up any outdated or obvious information
135+
- Add newly discovered non-obvious patterns
136+
- Improve organization and clarity
137+
- Ensure it follows the non-obvious-only principle
138+
139+
Content should include:
110140
- Header: "# AGENTS.md\\n\\nThis file provides guidance to agents when working with code in this repository."
111141
- Build/lint/test commands - ONLY if they differ from standard package.json scripts
112142
- Code style - ONLY project-specific rules not covered by linter configs
@@ -126,9 +156,20 @@ Please analyze this codebase and create an AGENTS.md file containing:
126156
</main_file>
127157
128158
<mode_specific_files>
129-
Additionally, create mode-specific rule directories and AGENTS.md files.
130-
For the complete list of available modes with detailed descriptions, refer to the system prompt.
131-
The system prompt contains comprehensive information about each mode's purpose, when to use it, and its specific capabilities.
159+
Create or deeply improve mode-specific AGENTS.md files.
160+
161+
CRITICAL: For each of these paths, check if the file exists FIRST:
162+
- ./.roo/rules-code/AGENTS.md
163+
- ./.roo/rules-debug/AGENTS.md
164+
- ./.roo/rules-ask/AGENTS.md
165+
- ./.roo/rules-architect/AGENTS.md
166+
167+
If files exist:
168+
- Perform deep analysis and improvement
169+
- Clean up redundant or obvious information
170+
- Add new non-obvious discoveries
171+
- Ensure consistency with main AGENTS.md
172+
- Reorganize for better clarity
132173
133174
Example structure:
134175
\`\`\`
@@ -144,11 +185,7 @@ Please analyze this codebase and create an AGENTS.md file containing:
144185
└── AGENTS.md # Architect mode specific instructions
145186
\`\`\`
146187
147-
Create or update mode-specific AGENTS.md files in:
148-
149188
.roo/rules-code/AGENTS.md - ONLY non-obvious coding rules discovered by reading files:
150-
- Check if this file already exists and read it first
151-
- Improve and update existing content rather than replacing
152189
- Custom utilities that replace standard approaches
153190
- Non-standard patterns unique to this project
154191
- Hidden dependencies or coupling between components
@@ -165,8 +202,6 @@ Please analyze this codebase and create an AGENTS.md file containing:
165202
\`\`\`
166203
167204
.roo/rules-debug/AGENTS.md - ONLY non-obvious debugging discoveries:
168-
- Check if this file already exists and read it first
169-
- Improve and update existing content rather than replacing
170205
- Hidden log locations not mentioned in docs
171206
- Non-standard debugging tools or flags
172207
- Gotchas that cause silent failures
@@ -183,8 +218,6 @@ Please analyze this codebase and create an AGENTS.md file containing:
183218
\`\`\`
184219
185220
.roo/rules-ask/AGENTS.md - ONLY non-obvious documentation context:
186-
- Check if this file already exists and read it first
187-
- Improve and update existing content rather than replacing
188221
- Hidden or misnamed documentation
189222
- Counterintuitive code organization
190223
- Misleading folder names or structures
@@ -201,8 +234,6 @@ Please analyze this codebase and create an AGENTS.md file containing:
201234
\`\`\`
202235
203236
.roo/rules-architect/AGENTS.md - ONLY non-obvious architectural constraints:
204-
- Check if this file already exists and read it first
205-
- Improve and update existing content rather than replacing
206237
- Hidden coupling between components
207238
- Undocumented architectural decisions
208239
- Non-standard patterns that must be followed
@@ -228,6 +259,7 @@ Please analyze this codebase and create an AGENTS.md file containing:
228259
- Be extremely concise - if it's obvious, don't include it
229260
- Every line should prevent a potential mistake or confusion
230261
- Test: Would an experienced developer be surprised by this information?
262+
- If updating existing files: Ensure deep improvement, not just appending
231263
</quality_criteria>
232264
233265
Remember: The goal is to create documentation that enables AI assistants to be immediately productive in this codebase, focusing on project-specific knowledge that isn't obvious from the code structure alone.`,

0 commit comments

Comments
 (0)