Skip to content

Commit dba64f5

Browse files
shinprclaude
andcommitted
fix: Add Pattern 5 (Insufficient Existing Code Investigation) to English rules
- Added Pattern 5 to ai-development-guide.md for preventing duplicate implementations - Updated all agent descriptions to reference pre-implementation code investigation process - Enhanced technical-designer.md with similar functionality search and decision workflow - Added pre-implementation verification steps to task-executor.md - Strengthened architecture validation checklist in code-reviewer.md - Added 'code-reading' and 'best-practices' tags to rules-index.yaml This ensures English documentation maintains parity with Japanese improvements for AI execution accuracy. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent d64afd5 commit dba64f5

File tree

6 files changed

+36
-10
lines changed

6 files changed

+36
-10
lines changed

.claude/agents-en/code-reviewer.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ You are a code review AI assistant specializing in Design Doc compliance validat
99
## Initial Required Tasks
1010

1111
Load and follow these rule files before starting:
12-
- @docs/rules/ai-development-guide.md - AI Development Guide
12+
- @docs/rules/ai-development-guide.md - AI Development Guide, pre-implementation existing code investigation process
1313
- @docs/rules/technical-spec.md - Technical Specifications
1414
- @docs/rules/typescript.md - TypeScript Development Rules
1515
- @docs/rules/project-context.md - Project Context
@@ -93,6 +93,8 @@ Load and follow these rule files before starting:
9393
- [ ] Data flow follows design
9494
- [ ] Component dependencies correct
9595
- [ ] Responsibilities properly separated
96+
- [ ] Existing codebase analysis section includes similar functionality investigation results
97+
- [ ] No unnecessary duplicate implementations (Pattern 5 from @docs/rules/ai-development-guide.md)
9698

9799
### Quality Validation
98100
- [ ] Comprehensive error handling

.claude/agents-en/task-executor.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ You are a specialized AI assistant for reliably executing individual tasks.
2727
## Mandatory Rules
2828

2929
Load and follow these rule files before starting:
30-
- @docs/rules/ai-development-guide.md - AI Development Guide
30+
- @docs/rules/ai-development-guide.md - AI Development Guide, pre-implementation existing code investigation process
3131
**Follow**: All rules for implementation, testing, and code quality
3232
⚠️ **Exception**: Quality assurance process (Phase1-6) and commits are out of scope
3333
- @docs/rules/typescript-testing.md - Testing Rules
@@ -62,8 +62,13 @@ ls docs/plans/tasks/*.md | grep -E "task-[0-9]{2}\.md$" | head -1
6262
- Complete understanding of task file
6363
- Confirm overall design document (_overview-*.md)
6464
- Grasp impact scope and common processing points
65+
- Check "Existing Codebase Analysis" section in Design Doc
6566

6667
### 3. Implementation Execution
68+
#### Pre-implementation Verification (Following @docs/rules/ai-development-guide.md Pattern 5)
69+
- Re-confirm no existing implementations of similar functionality exist
70+
- Follow decisions recorded in Design Doc (use existing/new implementation)
71+
- If new similar functionality discovered, pause implementation and report
6772
- If all checkboxes are `[x]`, report "already completed" and end
6873
- Staged implementation with incremental verification
6974
- Upon each step completion【Required】Update checkboxes using Edit tool:

.claude/agents-en/technical-designer.md

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Before starting work, be sure to read and follow these rule files:
1212
- @docs/rules/documentation-criteria.md - Documentation creation criteria
1313
- @docs/rules/technical-spec.md - Project technical specifications
1414
- @docs/rules/typescript.md - TypeScript development rules
15-
- @docs/rules/ai-development-guide.md - AI development guide
15+
- @docs/rules/ai-development-guide.md - AI development guide, pre-implementation existing code investigation process
1616
- @docs/rules/project-context.md - Project context
1717
- @docs/rules/architecture/implementation-approach.md - Metacognitive strategy selection process (used for implementation approach decisions)
1818
- @docs/rules/architecture/ architecture rule files (if exist)
@@ -50,7 +50,7 @@ Details of documentation creation criteria follow @docs/rules/documentation-crit
5050
### Existing Code Investigation【Required】
5151
Must be performed before Design Doc creation:
5252

53-
1. **Implementation Path Verification**
53+
1. **Implementation File Path Verification**
5454
- First grasp overall structure with `Glob: src/**/*.ts`
5555
- Then identify target files with `Grep: "class.*Service" --type ts` or feature names
5656
- Record and distinguish between existing implementation locations and planned new locations
@@ -59,9 +59,18 @@ Must be performed before Design Doc creation:
5959
- List major public methods of target service (about 5 important ones if over 10)
6060
- Identify call sites with `Grep: "ServiceName\." --type ts`
6161

62-
3. **Include in Design Doc**
62+
3. **Similar Functionality Search and Decision** (Pattern 5 prevention from @docs/rules/ai-development-guide.md)
63+
- Search existing code for keywords related to planned functionality
64+
- Look for implementations with same domain, responsibilities, or configuration patterns
65+
- Decision and action:
66+
- Similar functionality found → Use that implementation (do not create new implementation)
67+
- Similar functionality is technical debt → Create ADR improvement proposal before implementation
68+
- No similar functionality → Proceed with new implementation
69+
70+
4. **Include in Design Doc**
6371
- Always include investigation results in "## Existing Codebase Analysis" section
64-
- If planned path differs from actual path, clearly state the reason
72+
- Clearly document similar functionality search results (found implementations or "none")
73+
- Record adopted decision (use existing/improvement proposal/new implementation) and rationale
6574

6675
### Agreement Checklist【Most Important】
6776
Must be performed at the beginning of Design Doc creation:

.claude/agents-en/work-planner.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ You are a specialized AI assistant for creating work plan documents.
99
## Initial Mandatory Tasks
1010

1111
Before starting work, be sure to read and follow these rule files:
12-
- @docs/rules/ai-development-guide.md - AI development guide (task management principles)
12+
- @docs/rules/ai-development-guide.md - AI development guide, pre-implementation existing code investigation process, task management principles
1313
- @docs/rules/documentation-criteria.md - Documentation creation criteria
1414
- @docs/rules/technical-spec.md - Technical specifications
1515
- @docs/rules/typescript-testing.md - Testing rules
@@ -75,7 +75,7 @@ Execute file output immediately (considered approved at execution).
7575
5. **Design Doc Compliance**: All task completion criteria derived from Design Doc specifications
7676

7777
### Task Completion Definition: 3 Elements
78-
1. **Implementation Complete**: Code functions
78+
1. **Implementation Complete**: Code functions (including existing code investigation)
7979
2. **Quality Complete**: Tests, type checking, linting pass
8080
3. **Integration Complete**: Coordination with other components verified
8181

docs/rules-en/ai-development-guide.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,16 @@ function validateEmail(email: string, context: 'user' | 'contact' | 'admin') { /
8989
```
9090
- For low certainty cases, create minimal verification code first
9191

92+
### Pattern 5: Insufficient Existing Code Investigation
93+
**Symptom**: Duplicate implementations, architecture inconsistency, integration failures
94+
**Cause**: Insufficient understanding of existing code before implementation
95+
**Avoidance Methods**:
96+
- Before implementation, always search for similar functionality (using domain, responsibility, configuration patterns as keywords)
97+
- Similar functionality found → Use that implementation (do not create new implementation)
98+
- Similar functionality is technical debt → Create ADR improvement proposal before implementation
99+
- No similar functionality exists → Implement new functionality following existing design philosophy
100+
- Record all decisions and rationale in "Existing Codebase Analysis" section of Design Doc
101+
92102
## Debugging Techniques
93103

94104
### 1. Error Analysis Procedure

docs/rules-en/rules-index.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ rules:
4646

4747
ai-development-guide:
4848
file: "ai-development-guide.md"
49-
tags: [anti-patterns, technical-judgment, debugging, quality-commands, rule-of-three, implementation, type-safety, refactoring]
50-
typical-use: "Technical decision criteria, anti-pattern detection, debugging techniques, quality check commands, implementation failure avoidance"
49+
tags: [anti-patterns, technical-judgment, debugging, quality-commands, rule-of-three, implementation, type-safety, refactoring, code-reading, best-practices]
50+
typical-use: "Technical decision criteria, anti-pattern detection, debugging techniques, quality check commands, implementation best practices"
5151
size: medium
5252
key-references:
5353
- "Rule of Three - Martin Fowler"

0 commit comments

Comments
 (0)