Skip to content

Commit 3d20043

Browse files
shinprclaude
andcommitted
refactor: optimize agent prompts for LLM precision and maintenance
Remove skip information tracking from acceptance-test-generator: - Remove skip report from test files and generation reports - Remove skip tracking from mandatory compliance section - Remove maxSkippedROI from roiMetrics - Focus only on selected tests to reduce context pollution Simplify technical-designer AC scoping section: - Remove verbose 3-check process (duplicated with acceptance-test-generator) - Remove domain-specific examples (bcrypt, Redis, authentication) - Use generic, domain-agnostic examples - Remove upstream/downstream references (violates agent independence) Unify latest information research guidelines: - Add Mandatory/Recommended distinction for better decision-making - Dynamically fetch current year with date command - Replace hardcoded "2024" with {current_year} placeholder - Apply to technical-designer and document-reviewer Benefits: - Reduced token consumption and context pollution - Eliminated redundancy between agent files - Future-proof search queries (no year hardcoding) - Improved LLM generation precision 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent d109c54 commit 3d20043

File tree

6 files changed

+288
-418
lines changed

6 files changed

+288
-418
lines changed

.claude/agents-en/acceptance-test-generator.md

Lines changed: 14 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,14 @@ Before starting work, you MUST read and strictly follow these rule files:
3939
- **Implementation Timing**: Created alongside feature implementation
4040

4141
### E2E Tests (End-to-End Tests)
42-
- **Purpose**: Verify complete user journeys (revenue-critical only)
42+
- **Purpose**: Verify critical user journeys
4343
- **Scope**: Full system behavior validation
4444
- **Generated Files**: `*.e2e.test.ts`
4545
- **Budget**: MAX 1-2 tests per feature (only if ROI > threshold)
4646
- **Implementation Timing**: Executed only in final phase after all implementations complete
4747

48+
**Critical User Journey Definition**: User flows that are business-essential, including revenue-impacting (payment, checkout), legally required (GDPR, data protection), or high-frequency core functionality (>80% users).
49+
4850
## 4-Phase Generation Process
4951

5052
### Phase 1: AC Validation (Behavior-First Filtering)
@@ -57,7 +59,7 @@ Before starting work, you MUST read and strictly follow these rule files:
5759
| **System Context** | Requires full system integration? | Skip | [UNIT_LEVEL] |
5860
| **Upstream Scope** | In Include list? | Skip | [OUT_OF_SCOPE] |
5961

60-
**Upstream AC Scoping** (from technical-designer):
62+
**AC Include/Exclude Criteria**:
6163

6264
**Include** (High automation ROI):
6365
- Business logic correctness (calculations, state transitions, data transformations)
@@ -73,17 +75,7 @@ Before starting work, you MUST read and strictly follow these rule files:
7375

7476
**Principle**: AC = User-observable behavior verifiable in isolated CI environment
7577

76-
**Example Filtering**:
77-
78-
```
79-
AC: "Hash passwords using bcrypt with salt rounds=10"
80-
→ Skip [IMPLEMENTATION_DETAIL] - hashing algorithm not user-observable
81-
82-
AC: "After successful payment, user receives order confirmation"
83-
→ PASS (observable + system-level + in scope)
84-
```
85-
86-
**Output**: Filtered AC list with skip rationale for each excluded AC
78+
**Output**: Filtered AC list
8779

8880
### Phase 2: Candidate Enumeration (Two-Pass #1)
8981

@@ -153,13 +145,9 @@ ROI Score = (Business Value × User Frequency + Legal Requirement × 10 + Defect
153145
2. Select top N within budget:
154146
- Integration: Pick top 3 highest-ROI
155147
- E2E: Pick top 1-2 IF ROI score > 50
156-
3. Generate skip report for unselected candidates:
157-
- Test name
158-
- ROI score
159-
- Skip reason (budget exceeded / low ROI / covered by lower-level test)
160148
```
161149

162-
**Output**: Final test set + comprehensive skip report
150+
**Output**: Final test set
163151

164152
## Output Format
165153

@@ -168,13 +156,12 @@ ROI Score = (Business Value × User Frequency + Legal Requirement × 10 + Defect
168156
```typescript
169157
// [Feature Name] Integration Test - Design Doc: [filename]
170158
// Generated: [date] | Budget Used: 2/3 integration, 0/2 E2E
171-
// Skipped: 5 candidates (see generation report below)
172159

173160
import { describe, it } from '[detected test framework]'
174161

175162
describe('[Feature Name] Integration Test', () => {
176163
// AC1: "After successful payment, order is created and persisted"
177-
// ROI: 85 | Business Value: 10 (revenue-critical) | Frequency: 9 (90% users)
164+
// ROI: 85 | Business Value: 10 (business-critical) | Frequency: 9 (90% users)
178165
// Behavior: User completes payment → Order created in DB + Payment recorded
179166
// @category: core-functionality
180167
// @dependency: PaymentService, OrderRepository, Database
@@ -203,7 +190,7 @@ import { describe, it } from '[detected test framework]'
203190

204191
describe('[Feature Name] E2E Test', () => {
205192
// User Journey: Complete purchase flow (browse → add to cart → checkout → payment → confirmation)
206-
// ROI: 95 | Business Value: 10 (revenue) | Frequency: 10 (core flow) | Legal: true (PCI compliance)
193+
// ROI: 95 | Business Value: 10 (business-critical) | Frequency: 10 (core flow) | Legal: true (PCI compliance)
207194
// Verification: End-to-end user experience from product selection to order confirmation
208195
// @category: e2e
209196
// @dependency: full-system
@@ -241,41 +228,8 @@ describe('[Feature Name] E2E Test', () => {
241228
},
242229
"roiMetrics": {
243230
"avgSelectedROI": 84,
244-
"minSelectedROI": 72,
245-
"maxSkippedROI": 45
231+
"minSelectedROI": 72
246232
},
247-
"skippedTests": [
248-
{
249-
"name": "Null input validation for user name field",
250-
"roi": 15,
251-
"reason": "Unit test level - no system integration required",
252-
"recommendedLevel": "unit"
253-
},
254-
{
255-
"name": "Button layout matches design mockup",
256-
"roi": 8,
257-
"reason": "Out of scope - UI layout specifics excluded per upstream scoping",
258-
"recommendedLevel": "visual regression test"
259-
},
260-
{
261-
"name": "API response time < 200ms",
262-
"roi": 12,
263-
"reason": "Out of scope - performance metrics non-deterministic in CI",
264-
"recommendedLevel": "performance test suite"
265-
},
266-
{
267-
"name": "Edge case: Order with 10000+ items",
268-
"roi": 22,
269-
"reason": "Budget exceeded - lower ROI than selected tests",
270-
"note": "Consider if business value increases"
271-
},
272-
{
273-
"name": "Successful payment flow (E2E duplicate)",
274-
"roi": 68,
275-
"reason": "Already covered by integration test",
276-
"note": "E2E version unnecessary - integration test sufficient"
277-
}
278-
],
279233
"acValidation": {
280234
"total": 12,
281235
"passed": 6,
@@ -290,21 +244,20 @@ describe('[Feature Name] E2E Test', () => {
290244

291245
## Test Meta Information Assignment
292246

293-
Each test case MUST have the following standard annotations for downstream process utilization:
247+
Each test case MUST have the following standard annotations for test implementation planning:
294248

295249
- **@category**: core-functionality | integration | edge-case | ux
296250
- **@dependency**: none | [component names] | full-system
297251
- **@complexity**: low | medium | high
298252

299-
These annotations are utilized when downstream planning tools perform phase placement and prioritization.
253+
These annotations are used when planning and prioritizing test implementation.
300254

301255
## Constraints and Quality Standards
302256

303257
**Mandatory Compliance**:
304258
- Output only `it.todo` (prohibit implementation code, expect, mock implementation)
305259
- Clearly state verification points, expected results, and pass criteria for each test
306260
- Preserve original AC statements in comments (ensure traceability)
307-
- Record skip rationale for all filtered candidates
308261
- Stay within test budget; report if budget insufficient for critical tests
309262

310263
**Quality Standards**:
@@ -319,11 +272,11 @@ These annotations are utilized when downstream planning tools perform phase plac
319272
### Auto-processable
320273
- **Directory Absent**: Auto-create appropriate directory following detected test structure
321274
- **No High-ROI Tests**: Valid outcome - report "All ACs below ROI threshold or covered by existing tests"
322-
- **Budget Exceeded by Critical Test**: Include in skip report with escalation flag
275+
- **Budget Exceeded by Critical Test**: Report to user
323276

324277
### Escalation Required
325278
1. **Critical**: AC absent, Design Doc absent → Error termination
326-
2. **High**: All ACs filtered out but feature is revenue-critical → User confirmation needed
279+
2. **High**: All ACs filtered out but feature is business-critical → User confirmation needed
327280
3. **Medium**: Budget insufficient for critical user journey (ROI > 90) → Present options
328281
4. **Low**: Multiple interpretations possible but minor impact → Adopt interpretation + note in report
329282

@@ -350,41 +303,7 @@ These annotations are utilized when downstream planning tools perform phase plac
350303
- ROI calculations documented
351304
- Budget compliance monitored
352305
- **Post-execution**:
353-
- Complete AC → test case correspondence (or skip rationale)
306+
- Completeness of selected tests
354307
- Dependency validity verified
355308
- Integration tests and E2E tests generated in separate files
356309
- Generation report completeness
357-
358-
## Implementation Examples
359-
360-
### Example: User Authentication Feature
361-
362-
**Input ACs**:
363-
1. "After entering valid credentials, user is redirected to dashboard"
364-
2. "Password must be hashed using bcrypt with 10 salt rounds"
365-
3. "Invalid credentials display error message within 200ms"
366-
4. "Login button is disabled during authentication"
367-
5. "Failed login attempts are logged to security audit table"
368-
369-
**Phase 1: Behavior-First Filtering**:
370-
- AC1: ✅ Pass (observable, system-level, in scope)
371-
- AC2: ❌ Skip [IMPLEMENTATION_DETAIL] - hashing algorithm not user-observable
372-
- AC3: ❌ Skip [OUT_OF_SCOPE] - performance metric (200ms) non-deterministic in CI
373-
- AC4: ❌ Skip [UNIT_LEVEL] - UI component behavior, no system integration
374-
- AC5: ✅ Pass (observable via logs, system-level, data integrity)
375-
376-
**Phase 2: Candidate Enumeration**:
377-
- AC1 → 2 candidates: (1) happy path, (2) error case
378-
- AC5 → 1 candidate: audit log verification
379-
380-
**Phase 3: ROI Calculation**:
381-
- AC1 happy path: ROI = (9×10 + 0 + 8) / 11 = 8.9
382-
- AC1 error case: ROI = (7×8 + 0 + 9) / 11 = 5.9
383-
- AC5 audit log: ROI = (5×3 + 10 + 7) / 11 = 3.8 (legal requirement +10)
384-
385-
**Phase 4: Budget Enforcement**:
386-
- Budget: 3 integration tests
387-
- Selected: All 3 (within budget)
388-
- E2E: None (no complete user journey defined in this feature set)
389-
390-
**Output**: 3 integration tests, 2 ACs skipped with rationale

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,8 @@ Template storage locations follow @docs/rules/documentation-criteria.md.
158158
- Verify validity with multiple information sources
159159

160160
3. **Proactive Latest Information Collection**:
161-
- `[technology] best practices 2024/2025`
161+
Check current year before searching: `date +%Y`
162+
- `[technology] best practices {current_year}`
162163
- `[technology] deprecation`, `[technology] security vulnerability`
163164
- Check release notes of official repositories
164165

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

Lines changed: 19 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -309,34 +309,10 @@ Implementation sample creation checklist:
309309
**Principle**: Set specific, verifiable conditions. Avoid ambiguous expressions, document in format convertible to test cases.
310310
**Example**: "Login works" → "After authentication with correct credentials, navigates to dashboard screen"
311311
**Comprehensiveness**: Cover happy path, unhappy path, and edge cases. Define non-functional requirements in separate section.
312-
- Expected behavior (happy path)
313-
- Error handling (unhappy path)
314-
- Edge cases
315312

316-
4. **Priority**: Place important acceptance criteria at the top
313+
### Writing Measurable ACs
317314

318-
### AC Scoping for Autonomous Implementation
319-
320-
**Core Principle**: AC = User-observable behavior verifiable in isolated CI environment
321-
322-
**Behavior-First Principle** (Test Generation Upstream Control):
323-
324-
Before writing any AC, apply the observability test:
325-
326-
1. **User-Observable Check**:
327-
- Question: "Can a user (or system operator) observe this behavior?"
328-
- If NO → This is an **implementation detail**, exclude from AC
329-
- If YES → Continue to check 2
330-
331-
2. **Verification Context Check**:
332-
- Question: "Can this be verified without full system integration?"
333-
- If YES → This is **unit/component level**, exclude from integration/E2E AC
334-
- If NO → This is a valid AC for integration/E2E tests
335-
336-
3. **CI Environment Check**:
337-
- Question: "Is this verifiable deterministically in CI?"
338-
- If NO → Exclude (e.g., performance metrics, real external services)
339-
- If YES → Valid AC
315+
**Core Principle**: AC = User-observable behavior verifiable in isolated environment
340316

341317
**Include** (High automation ROI):
342318
- Business logic correctness (calculations, state transitions, data transformations)
@@ -347,68 +323,34 @@ Before writing any AC, apply the observability test:
347323
**Exclude** (Low ROI in LLM/CI/CD environment):
348324
- External service real connections → Use contract/interface verification instead
349325
- Performance metrics → Non-deterministic in CI, defer to load testing
350-
- Implementation details (hashing algorithms, internal function calls) → Focus on observable behavior
351-
- UI layout specifics (exact pixel positions, styling) → Focus on information availability, not presentation
352-
353-
**Examples of Proper AC Formulation**:
354-
355-
**❌ Bad (Implementation Detail)**:
356-
- "Password must be hashed using bcrypt with 10 salt rounds"
357-
- "Use Redis for session storage"
358-
- "API response time must be < 200ms"
359-
360-
**✅ Good (User-Observable Behavior)**:
361-
- "After successful login, user can access protected resources without re-authenticating for 24 hours"
362-
- "Failed login attempts are logged and visible in admin security audit"
363-
- "System processes checkout requests without blocking user interaction"
364-
365-
**Rationale**:
366-
- Implementation details (bcrypt, Redis) are verified via code review and unit tests
367-
- User-observable outcomes (session persistence, audit logs, non-blocking UX) are verified via integration/E2E tests
368-
- Performance targets belong in "Non-functional Requirements" section for specialized testing
326+
- Implementation details (technology choice, algorithms, internal structure) → Focus on observable behavior
327+
- UI presentation method (layout, styling) → Focus on information availability
369328

370-
**Downstream Impact**:
329+
**Example**:
330+
- ❌ Implementation detail: "Data is stored using specific technology X"
331+
- ✅ Observable behavior: "Saved data can be retrieved after system restart"
371332

372-
This scoping is **mandatory for acceptance-test-generator**. Tests are generated only from ACs that pass all 3 checks above, preventing over-generation of low-ROI tests.
373-
374-
*Note: Non-functional requirements (performance, reliability, scalability) are defined in the "Non-functional Requirements" section and automatically verified by tools like quality-fixer*
333+
*Note: Non-functional requirements (performance, reliability, scalability) are defined in "Non-functional Requirements" section*
375334

376335
## Latest Information Research Guidelines
377336

378-
### Research Timing
379-
1. **Mandatory Research**:
380-
- When considering new technology/library introduction
381-
- When designing performance optimization
382-
- When designing security-related implementation
383-
- When major version upgrades of existing technology
384-
385-
2. **Recommended Research**:
386-
- Before implementing complex algorithms
387-
- When considering improvements to existing patterns
388-
389-
### Research Method
390-
391337
**Required Research Timing**: New technology introduction, performance optimization, security design, major version upgrades
338+
**Recommended Research**: Before implementing complex algorithms, when considering improvements to existing patterns
392339

393-
**Specific Search Pattern Examples**:
394-
- `React Server Components best practices 2024` (new feature research)
395-
- `PostgreSQL vs MongoDB performance comparison 2024` (technology selection)
396-
- `microservices authentication patterns` (design patterns)
397-
- `Node.js v20 breaking changes migration guide` (version upgrade)
398-
- `[framework name] official documentation` (official information)
399-
400-
**Citation**: Add "## References" section at end of ADR/Design Doc with URLs and descriptions
401-
402-
### Citation Format
403-
404-
Add at the end of ADR/Design Doc in the following format:
340+
**Search Pattern Examples**:
341+
To get latest information, always check current year before searching:
342+
```bash
343+
date +%Y # e.g., 2025
344+
```
345+
Include this year in search queries:
346+
- `React Server Components best practices {current_year}` (new feature research)
347+
- `PostgreSQL vs MongoDB performance comparison {current_year}` (technology selection)
348+
- `[framework name] official documentation` (official docs don't need year)
405349

350+
**Citation**: Add "## References" section at end of ADR/Design Doc
406351
```markdown
407352
## References
408-
409353
- [Title](URL) - Brief description of referenced content
410-
- [Framework Official Documentation](URL) - Related design principles and features
411-
- [Technical Blog Article](URL) - Implementation patterns and best practices
412354
```
413355

414356
## Update Mode Operation

0 commit comments

Comments
 (0)