Guide for creating optimized Claude Code agents. Use to design a new specialized agent, a swarm sub-agent, or a multi-agent workflow. Follows the Skill → Agent (preloaded skills) → Skill orchestration pattern.
日本語の概要は準備中です。原文の説明を表示しています。
Interactive guide for Detroit School TDD. Use whenever the user asks to write or modify code - new feature, bug fix, debug, refactoring, modification. Activates a RED-GREEN-REFACTOR workflow with validation at each step.
日本語の概要は準備中です。原文の説明を表示しています。
インストールする前に、エージェントに与えられる指示の中身を確認できます。
Read .claude/roles/senior-dev.md — adopt this profile and follow all its rules.
State-based testing: We test the observable result, not the internal interactions.
| Principle | Explanation |
|---|---|
| Test state | Verify the final result, not how we got there |
| Inside-Out | Start from the domain, work outward |
| Minimal mocks | Only for external I/O (gateways, API, DB) |
| Robust tests | Resistant to internal refactoring |
When to mock:
// Detroit: we test the final STATE of the result
it("should enqueue a review job", () => {
const queue = new ReviewQueue();
queue.enqueue({ mrId: "mr-42", platform: "gitlab" });
expect(queue.pending).toHaveLength(1);
expect(queue.peek()?.mrId).toBe("mr-42");
});
// London: we test interactions (avoid this in this project)
it("should call dispatcher.notify", () => {
const dispatcher = mock<JobDispatcher>();
queue.enqueue({ mrId: "mr-42", platform: "gitlab" });
expect(dispatcher.notify).toHaveBeenCalled();
});
ReviewFlow example (project-relevant test):
// src/tests/units/entities/reviewScore.test.ts
describe("ReviewScore", () => {
// Detroit: we test the STATE of the result
it("should create a valid review score", () => {
const score = createReviewScore(8);
expect(score.value).toBe(8);
expect(score.label).toBe("good");
});
// Validation before use
it("should reject a score below 0", () => {
const result = createReviewScore(-1);
expect(result).toBeNull(); // Final state
});
// Boundary validation
it("should reject a score above 10", () => {
const result = createReviewScore(11);
expect(result).toBeNull(); // Final state
});
});
TDD follows these fundamental principles:
| Principle | Meaning |
|---|---|
| Baby steps | Small steps for fast and regular feedback |
| Continuous refactoring | We improve now, not "later" |
| Evolutionary design | We develop what is necessary and sufficient |
| Executable documentation | Tests ARE the living documentation |
| Minimalist code | Simple and functional > over-dimensioned |
"The simplest thing that could possibly work." — Kent Beck
"As the tests get more specific, the code gets more generic." — Robert C. Martin
Rules:
Typical progression:
Cycle 1: "should create a completion" (nominal case)
Cycle 2: "should have a rating" (property)
Cycle 3: "should reject rating below 1" (validation)
Cycle 4: "should reject rating above 5" (validation)
Anti-pattern:
// Test too broad
it("should validate a completion with rating 1-5 and ISO datetime", () => {
// tests rating min, max, date format, nominal case...
})
// One behavior per test
it("should create a completion", () => { ... })
it("should reject rating below 1", () => { ... })
The Transformation Priority Premise guides the RED → GREEN transition. When writing minimal code to pass a test, we apply transformations — and these transformations have a natural priority order.
Always choose the highest transformation in the list (the simplest). Skipping steps often leads to suboptimal design.
| Priority | Transformation | Description | Example |
|---|---|---|---|
| 1 | {} → nil | No code → return null/undefined | return undefined |
| 2 | nil → constant | Return a hardcoded value | return [] |
| 3 | constant → variable | Replace constant with parameter | return items instead of return [] |
| 4 | unconditional → conditional | Add a branch | if (age < 18) return false |
| 5 | scalar → collection | Go from single value to array | string → string[] |
| 6 | statement → recursion/iteration | Loop over the collection | items.map(transform) |
| 7 | value → mutated value | Transform the accumulated value | items.reduce(accumulate) |
The TPP is a guide, not an absolute rule. It is particularly useful when:
Less relevant for simple orchestration code (call a gateway and return the result).
// RED: test "should return empty list when no tags"
// GREEN via {} → constant:
return [];
// RED: test "should return formatted tag for single item"
// GREEN via constant → variable:
return [formatTag(tags[0])];
// RED: test "should return formatted tags for multiple items"
// GREEN via scalar → collection + iteration:
return tags.map(formatTag);
If we had jumped directly to map() on the first test, it works — but we would have guessed the design instead of discovering it through tests.
If during GREEN phase you end up writing more than 3-5 lines of code, you're probably skipping transformations. Options:
This skill activates whenever the user asks to touch code:
At each cycle, follow these 3 phases with stop and user validation between each.
Goal: Write ONE failing test
Actions:
yarn test:run to confirm failureTemplate:
RED - Test Proposal
Behavior to test: [description]
File: [path]
Proposed test:
[test code - state-based, verifies the result]
This test verifies that [explanation of expected state].
Validate this test?
Goal: Make the test pass with MINIMAL code
Actions:
yarn test:run to confirm successRules:
Template:
GREEN - Implementation Proposal
To make the test pass, I propose:
[minimal code]
This is intentionally minimal because [explanation].
Validate this implementation?
Goal: Simplify without changing behavior
Principles:
Actions:
yarn test:run after each refactoringPriority order: Remove > Simplify > Reorganize
Template:
REFACTOR - Analysis
Code smells detected:
- [smell 1]: [explanation]
Proposed refactoring:
[description of change]
Apply this refactoring?
The test becomes a protective regression test.
Never move to the next phase without:
TDD relies on progressive design discovery. Specs/tickets must NOT contain:
| Forbidden | Why |
|---|---|
| Test names | The test emerges from the need, not the other way around |
| File names | Architecture reveals itself through iteration |
| Method signatures | Design comes from the simplest code |
| Installation commands | Dependencies come when necessary |
Principle: We don't predict the final code. We proceed by baby steps, from the most naive implementation to the final case.
Ticket with "Tests to implement: should_create_user_with_email"
Ticket with "Files: src/services/user.service.ts"
Ticket with "Method: createUser(email: string): User"
Ticket with Gherkin criteria describing the expected BEHAVIOR
The RED-GREEN-REFACTOR cycle makes the design emerge. The ticket describes the WHAT (behavior), not the HOW (implementation).
Cycle Complete
Tests added: [number]
Behaviors covered: [list]
Next suggested behavior: [suggestion]
Continue?
まだレビューはありません。使ってみた感想をお寄せください。
ログインなしで書き込めます。使ってみた感想、質問、動かなかった環境などを気軽にどうぞ。
まだコメントはありません。最初のコメントを書いてみませんか。
Guide for creating optimized Claude Code agents. Use to design a new specialized agent, a swarm sub-agent, or a multi-agent workflow. Follows the Skill → Agent (preloaded skills) → Skill orchestration pattern.
日本語の概要は準備中です。原文の説明を表示しています。
Anti-overengineering guide based on YAGNI. Use before adding an architectural pattern, during code review, or to challenge an overly complex implementation.
日本語の概要は準備中です。原文の説明を表示しています。
Clean Architecture (Uncle Bob) guide for this project. Use when creating modules, entities, use cases, presenters, controllers, gateways, guards, services. Contains tactical patterns and structure conventions.
日本語の概要は準備中です。原文の説明を表示しています。
Audit documentation for duplication, staleness, language issues, and verbosity. Read-only — produces an actionable report.
日本語の概要は準備中です。原文の説明を表示しています。
Local auto-review of modified code (no GitLab/GitHub). Runs 5 sequential audits and generates a local report. Ideal for validating code before creating a MR/PR.
日本語の概要は準備中です。原文の説明を表示しています。
Clean Code (Robert C. Martin) guide to produce and challenge code that is readable, durable, simple, and consistent. Covers naming, functions, comments, smells, and refactor heuristics. Complements `/solid` (SOLID principles) and `/anti-overengineering` (YAGNI/KISS). Activate during the REFACTOR phase of the TDD cycle and during implementation self-review.
日本語の概要は準備中です。原文の説明を表示しています。