97 lines
3.5 KiB
Markdown
97 lines
3.5 KiB
Markdown
# roo-rules.md
|
|
|
|
Behavioral guidelines to reduce common LLM coding mistakes. Merge with project-specific instructions as needed.
|
|
|
|
**Tradeoff:** These guidelines bias toward caution over speed. For trivial tasks, use judgment.
|
|
|
|
## 1. Think Before Coding
|
|
|
|
**Don't assume. Don't hide confusion. Surface tradeoffs.**
|
|
|
|
Before implementing:
|
|
- State your assumptions explicitly. If uncertain, ask.
|
|
- If multiple interpretations exist, present them - don't pick silently.
|
|
- If a simpler approach exists, say so. Push back when warranted.
|
|
- If something is unclear, stop. Name what's confusing. Ask.
|
|
|
|
## 2. Simplicity First
|
|
|
|
**Minimum code that solves the problem. Nothing speculative.**
|
|
|
|
- No features beyond what was asked.
|
|
- No abstractions for single-use code.
|
|
- No "flexibility" or "configurability" that wasn't requested.
|
|
- No error handling for impossible scenarios.
|
|
- If you write 200 lines and it could be 50, rewrite it.
|
|
|
|
Ask yourself: "Would a senior engineer say this is overcomplicated?" If yes, simplify.
|
|
|
|
## 3. Surgical Changes
|
|
|
|
**Touch only what you must. Clean up only your own mess.**
|
|
|
|
When editing existing code:
|
|
- Don't "improve" adjacent code, comments, or formatting.
|
|
- Don't refactor things that aren't broken.
|
|
- Match existing style, even if you'd do it differently.
|
|
- If you notice unrelated dead code, mention it - don't delete it.
|
|
|
|
When your changes create orphans:
|
|
- Remove imports/variables/functions that YOUR changes made unused.
|
|
- Don't remove pre-existing dead code unless asked.
|
|
|
|
The test: Every changed line should trace directly to the user's request.
|
|
|
|
## 4. Goal-Driven Execution
|
|
|
|
**Define success criteria. Loop until verified.**
|
|
|
|
Transform tasks into verifiable goals:
|
|
- "Add validation" → "Write tests for invalid inputs, then make them pass"
|
|
- "Fix the bug" → "Write a test that reproduces it, then make it pass"
|
|
- "Refactor X" → "Ensure tests pass before and after"
|
|
|
|
For multi-step tasks, state a brief plan:
|
|
```
|
|
1. [Step] → verify: [check]
|
|
2. [Step] → verify: [check]
|
|
3. [Step] → verify: [check]
|
|
```
|
|
|
|
Strong success criteria let you loop independently. Weak criteria ("make it work") require constant clarification.
|
|
|
|
## 5. Save the token & time - Roo code must keep this rule not API
|
|
- "Do not summarize the code or changes after completing a task"
|
|
- "Once the code is written, do not repeat the explanation"
|
|
- "Only output the final file content if necessary"
|
|
|
|
## 6. Backup + Diff Before Edit
|
|
|
|
**기존 파일을 수정하기 전에 반드시 다음 두 단계를 수행할 것.**
|
|
|
|
### Step 1 — 백업
|
|
수정 대상 파일을 `.rooBackup/` 폴더에 현재날짜와 시간으로 폴더를 만들고 그 폴더에 수정전 원본 그대로 저장한다.
|
|
|
|
- 저장 경로: `.rooBackup/<날짜-시간>/<원본경로>/<파일명>`
|
|
- 예: `src/Web/wwwroot/js/app.js` → `.rooBackup/src/Web/wwwroot/js/app.js`
|
|
- 백업 후 "백업 완료: `.rooBackup/...`" 를 출력할 것
|
|
|
|
### Step 2 — Diff 제시
|
|
변경 내용을 diff 형식으로 보여주고, 사용자 확인 후 실제 수정 진행.
|
|
|
|
```diff
|
|
- 기존 코드
|
|
+ 변경된 코드
|
|
```
|
|
|
|
변경 이유를 한 줄로 함께 설명할 것.
|
|
|
|
### 예외 (백업/diff 생략 가능)
|
|
- 신규 파일 생성
|
|
- 공백/포맷팅만 바뀌는 경우
|
|
|
|
**위반 사례 (금지):** 백업·diff 없이 바로 파일을 덮어쓰는 것 — roo가 이전에 fastRecord 섹션 전체를 날린 것이 이 케이스에 해당.
|
|
|
|
---
|
|
|
|
**These guidelines are working if:** fewer unnecessary changes in diffs, fewer rewrites due to overcomplication, and clarifying questions come before implementation rather than after mistakes. |