EasyPlatform tdd-spec
[Testing] Generate or update test specifications in feature docs (Section 15) with unified TC-{FEATURE}-{NNN} format. Supports TDD-first, implement-first, update, and sync modes.
git clone https://github.com/duc01226/EasyPlatform
T=$(mktemp -d) && git clone --depth=1 https://github.com/duc01226/EasyPlatform "$T" && mkdir -p ~/.claude/skills && cp -r "$T/.claude/skills/tdd-spec" ~/.claude/skills/duc01226-easyplatform-tdd-spec && rm -rf "$T"
.claude/skills/tdd-spec/SKILL.md<!-- /SYNC:critical-thinking-mindset --> <!-- SYNC:ai-mistake-prevention -->Critical Thinking Mindset — Apply critical thinking, sequential thinking. Every claim needs traced proof, confidence >80% to act. Anti-hallucination: Never present guess as fact — cite sources for every claim, admit uncertainty freely, self-check output for errors, cross-reference independently, stay skeptical of own confidence — certainty without evidence root of all hallucination.
<!-- /SYNC:ai-mistake-prevention -->AI Mistake Prevention — Failure modes to avoid on every task:
- Check downstream references before deleting. Deleting components causes documentation and code staleness cascades. Map all referencing files before removal.
- Verify AI-generated content against actual code. AI hallucinates APIs, class names, and method signatures. Always grep to confirm existence before documenting or referencing.
- Trace full dependency chain after edits. Changing a definition misses downstream variables and consumers derived from it. Always trace the full chain.
- Trace ALL code paths when verifying correctness. Confirming code exists is not confirming it executes. Always trace early exits, error branches, and conditional skips — not just happy path.
- When debugging, ask "whose responsibility?" before fixing. Trace whether bug is in caller (wrong data) or callee (wrong handling). Fix at responsible layer — never patch symptom site.
- Assume existing values are intentional — ask WHY before changing. Before changing any constant, limit, flag, or pattern: read comments, check git blame, examine surrounding code.
- Verify ALL affected outputs, not just the first. Changes touching multiple stacks require verifying EVERY output. One green check is not all green checks.
- Holistic-first debugging — resist nearest-attention trap. When investigating any failure, list EVERY precondition first (config, env vars, DB names, endpoints, DI registrations, data preconditions), then verify each against evidence before forming any code-layer hypothesis.
- Surgical changes — apply the diff test. Bug fix: every changed line must trace directly to the bug. Don't restyle or improve adjacent code. Enhancement task: implement improvements AND announce them explicitly.
- Surface ambiguity before coding — don't pick silently. If request has multiple interpretations, present each with effort estimate and ask. Never assume all-records, file-based, or more complex path.
TDD Spec — Test-Driven Specification Writer
[MANDATORY] You MUST ATTENTION use
to break ALL work into small tasks BEFORE starting. NEVER skip task creation.TaskCreate
External Memory: For complex or lengthy work (research, analysis, scan, review), write intermediate findings and final results to a report file in
— prevents context loss and serves as deliverable.plans/reports/
<!-- SYNC:rationalization-prevention -->Evidence Gate: MANDATORY IMPORTANT MUST ATTENTION — every claim, finding, and recommendation requires
proof or traced evidence with confidence percentage (>80% to act, <80% must verify first).file:line
<!-- /SYNC:rationalization-prevention -->Rationalization Prevention — AI skips steps via these evasions. Recognize and reject:
Evasion Rebuttal "Too simple for a plan" Simple + wrong assumptions = wasted time. Plan anyway. "I'll test after" RED before GREEN. Write/verify test first. "Already searched" Show grep evidence with . No proof = no search.file:line"Just do it" Still need TaskCreate. Skip depth, never skip tracking. "Just a small fix" Small fix in wrong location cascades. Verify file:line first. "Code is self-explanatory" Future readers need evidence trail. Document anyway. "Combine steps to save time" Combined steps dilute focus. Each step has distinct purpose.
Graph Context (MANDATORY when graph.db exists): Before generating test specs, run graph impact analysis. This reveals cross-service consumers, event handlers, and implicit connections (MESSAGE_BUS, API_ENDPOINT, TRIGGERS_EVENT) that tests must cover.
Quick Summary
Goal: Generate or update test specifications in feature docs Section 15 (canonical TC registry) using the unified
TC-{FEATURE}-{NNN} format. Supports 5 modes: TDD-first, implement-first, update (post-change/PR), sync, and from-integration-tests.
Be skeptical. Apply critical thinking, sequential thinking. Every claim needs traced proof, confidence percentages (Idea should be more than 80%).
MANDATORY IMPORTANT MUST ATTENTION Plan ToDo Task to READ the following project-specific reference doc:
<!-- SYNC:evidence-based-reasoning --><!-- /SYNC:evidence-based-reasoning --> <!-- SYNC:cross-cutting-quality -->Evidence-Based Reasoning — Speculation is FORBIDDEN. Every claim needs proof.
- Cite
, grep results, or framework docs for EVERY claimfile:line- Declare confidence: >80% act freely, 60-80% verify first, <60% DO NOT recommend
- Cross-service validation required for architectural changes
- "I don't have enough evidence" is valid and expected output
BLOCKED until:
Evidence file path (- [ ])file:lineGrep search performed- [ ]3+ similar patterns found- [ ]Confidence level stated- [ ]Forbidden without proof: "obviously", "I think", "should be", "probably", "this is because" If incomplete → output:
"Insufficient evidence. Verified: [...]. Not verified: [...]."<!-- /SYNC:cross-cutting-quality -->Cross-Cutting Quality — Check across all changed files:
- Error handling consistency — same error patterns across related files
- Logging — structured logging with correlation IDs for traceability
- Security — no hardcoded secrets, input validation at boundaries, auth checks present
- Performance — no N+1 queries, unnecessary allocations, or blocking calls in async paths
- Observability — health checks, metrics, tracing spans for new endpoints
— TC template format.claude/skills/tdd-spec/references/tdd-spec-template.md — Domain entity catalog, relationships, cross-service sync (read when task involves business entities/models) (content auto-injected by hook — check for [Injected: ...] header before reading)docs/project-reference/domain-entities-reference.md — Integration test patterns, fixture setup, seeder conventions, lessons learned (MUST READ before reviewing/writing integration tests)docs/project-reference/integration-test-reference.md — Test specifications by module (read existing TCs before generating new to avoid duplicates and maintain TC ID continuity)docs/test-specs/
Workflow:
- Mode Detection — Determine mode: TDD-first, implement-first, update, sync, or from-integration-tests
- Investigation — Analyze PBI/codebase/existing TCs/git changes based on mode
- TC Generation — Generate TC outlines, review interactively with user
- Write to Feature Doc — Upsert TCs into target feature doc Section 15
- Dashboard Sync — Optionally update
cross-module dashboarddocs/test-specs/ - Next Steps — Suggest follow-on actions based on mode
Key Rules:
- Unified format:
— feature codes inTC-{FEATURE}-{NNN}docs/project-reference/feature-docs-reference.md - Source of truth: Feature docs Section 15 is the canonical TC registry
- Evidence required: Every TC MUST ATTENTION have
orEvidence: {FilePath}:{LineRange}
for TDD-first modeTBD (pre-implementation) - Minimum 4 categories: Positive (happy path), negative (error handling), authorization (role-based access), edge cases (for bugfix specs: MANDATORY Preservation Tests category — see
)references/tdd-spec-template.md#preservation-tests-mandatory-for-bugfix-specs - Cross-cutting TC categories:
- Authorization TCs (mandatory): Authorized access succeeds, unauthorized access rejected, role-based visibility verified
- Seed Data TCs (if applicable): Reference data exists, seeder runs correctly
- Performance TCs (if applicable): Feature performs within SLA under production-like data volume
- Data Migration TCs (if applicable): Data transforms correctly, rollback works, no data loss
- Preservation TCs (MANDATORY for bugfixes): ≥1 preservation test per "Healthy input" row in the plan's Preservation Inventory. Authored from OLD code's semantics BEFORE fix lands. See
.references/tdd-spec-template.md#preservation-tests-mandatory-for-bugfix-specs
- Interactive review: ALWAYS use
to review TC list with user before writingAskUserQuestion
Quick Reference
Related Skills
| Skill | Relationship |
|---|---|
| Heavyweight planning/investigation → feeds into this skill |
| Dashboard writer → syncs FROM feature docs Section 15 |
| Code generator → generates integration tests FROM TCs written by this skill |
| Feature doc creator → creates the Section 15 that this skill populates |
Output Locations
| Artifact | Path |
|---|---|
| TCs (canonical) | Section 15 |
| Dashboard (optional) | Implementation Index |
| Priority index (optional) | |
Phase-Mapped Coverage: When a plan exists with multiple phases, generate test cases PER PHASE — not just per feature. Each phase's success criteria MUST ATTENTION have ≥1 test case.
Frontend/UI Context (if applicable)
<!-- SYNC:ui-system-context -->When this task involves frontend or UI changes,
<!-- /SYNC:ui-system-context -->UI System Context — For ANY task touching
,.ts,.html, or.scssfiles:.cssMUST ATTENTION READ before implementing:
— component base classes, stores, formsdocs/project-reference/frontend-patterns-reference.md — BEM methodology, SCSS variables, mixins, responsivedocs/project-reference/scss-styling-guide.md — design tokens, component inventory, iconsdocs/project-reference/design-system/README.mdReference
for project-specific paths.docs/project-config.json
- Component patterns:
docs/project-reference/frontend-patterns-reference.md - Styling/BEM guide:
docs/project-reference/scss-styling-guide.md - Design system tokens:
docs/project-reference/design-system/README.md
Detailed Workflow
Phase 1: Mode Detection & Context
Detect mode from user prompt and context:
| Mode | Signal | Action |
|---|---|---|
| TDD-first | PBI/story exists, code not yet written | Generate specs from requirements |
| Implement-first | Code already exists, no/incomplete TCs | Generate specs from codebase analysis |
| Update | Existing TCs + code changes / bugfix / PR | Diff existing TCs against current code/PR, find gaps, update both |
| Sync | User says "sync test specs" or bidirectional need | Reconcile feature docs ↔ docs/test-specs/ (either direction) |
| From-integration-tests | Tests exist with test spec annotations, no docs | Extract TC metadata from test code → write to feature docs |
Must read FIRST:
— identify the correctdocs/project-reference/feature-docs-reference.md
code for TC IDs{FEATURE}- Target feature doc — check if Section 15 exists, read existing TCs to avoid ID collisions
If target feature doc doesn't exist:
- Suggest running
first, OR/feature-docs - Create a minimal Section 15 stub in the appropriate feature doc
Phase 2: Investigation
TDD-first mode:
- Read the PBI/story document (from
or user-provided)team-artifacts/pbis/ - Extract acceptance criteria
- Identify test categories: CRUD operations, validation rules, authorization (mandatory), workflows, edge cases, seed data, performance data, data migration
- Cross-reference with existing feature doc requirements (Sections 1-14)
- Cross-reference PBI Authorization section → generate authorization TCs (unauthorized access rejection per role)
- Cross-reference PBI Seed Data section → generate seed data TCs if reference/config data needed
- Cross-reference PBI Data Migration section → generate migration TCs if schema changes exist
Implement-first mode:
- Grep for commands/queries in the target service:
grep -r "class.*Command.*:" src/Services/{service}/ - Grep for entities and domain events
- Trace code paths: Controller → Command → Handler → Entity → Event Handler
- Identify testable behaviors from actual implementation
Update mode (post-change / post-bugfix / post-PR):
- Read existing Section 15 TCs
orgit diff
(for PRs) to find code changes since TCs were last updatedgit diff main...HEAD- Identify: new commands/queries not covered, changed behaviors, removed features
- For bugfixes: add a regression TC for the bug that was fixed (e.g.,
)TC-GM-040: Regression — goal title validation bypass - Generate gap analysis
- Update both feature docs Section 15 AND
dashboarddocs/test-specs/
Sync mode (bidirectional reconciliation):
- Read feature docs Section 15 TCs for target module
- Read
TCsdocs/test-specs/{Module}/README.md - Read test files: grep for test spec annotations in
src/Services/{service}*.IntegrationTests/ - Build 3-way comparison table:
| TC ID | In Feature Doc? | In test-specs/? | In Test Code? | Action Needed | |-------|----------------|-----------------|---------------|---------------| | TC-OM-001 | ✅ | ✅ | ✅ | None | | TC-OM-025 | ✅ | ❌ | ✅ | Add to test-specs/ | | TC-OM-030 | ❌ | ✅ | ❌ | Add to feature doc |
- Reconcile: write missing TCs to whichever system lacks them
- Feature docs remain source of truth — any conflict uses feature doc version
From-integration-tests mode (reverse-engineer specs from existing tests):
- Grep for
in target test project[Trait("TestSpec", "TC-...")] - For each test method: extract TC ID, method name, test description from comments
- Read the test method body to generate GWT steps and evidence
- Write extracted TCs to feature doc Section 15 (if not already there)
- Useful when: tests were written before the spec system existed, or imported from another project
Phase 3: TC Generation with Interactive Review
- Generate TC outlines as a summary table:
| TC ID | Name | Priority | Category | Status | |-------|------|----------|----------|--------| | TC-GM-037 | Create goal with cascading key results | P0 | CRUD | New | | TC-GM-038 | Reject goal without required title | P1 | Validation | New | | TC-GM-039 | External user cannot access goals | P0 | Permission | New |
- Use
to review with user:AskUserQuestion
Question: "These {N} test cases cover {feature}. Review the list:" Options: - "Approve as-is (Recommended)" — Proceed to writing - "Add missing scenario" — Describe what's missing - "Adjust priorities" — Change P0/P1/P2 assignments - "Regenerate" — Re-analyze and try again
- Iterate until user approves.
Phase 4: Write to Feature Doc Section 15
This is the canonical write — feature docs own the TCs.
- Locate Section 15 in target feature doc
- If Section 15 exists: append new TCs after existing ones, preserving existing TC IDs
- If Section 15 doesn't exist: create it from template
- Use
tool to upsert — never overwrite existing TCsEdit
TC format (from
tdd-spec-template.md):
#### TC-{FEATURE}-{NNN}: {Descriptive Test Name} [{Priority}] **Objective:** {What this test verifies} **Preconditions:** - {Setup requirement} **Test Steps:** \`\`\`gherkin Given {initial state} And {additional context} When {action} Then {expected outcome} And {additional verification} \`\`\` **Acceptance Criteria:** - ✅ {Success behavior} - ❌ {Failure behavior} **Test Data:** \`\`\`json { "field": "value" } \`\`\` **Edge Cases:** - {Boundary condition} **Evidence:** `{FilePath}:{LineRange}` or `TBD (pre-implementation)`
Evidence rules by mode:
- TDD-first:
— will be updated after implementationEvidence: TBD (pre-implementation) - Implement-first:
— trace to real codeEvidence: {actual file}:{actual lines} - Update: Update existing evidence references if code moved
Phase 5: Update docs/test-specs/ Dashboard (Optional)
If
docs/test-specs/{Module}/README.md exists:
- Update the Implementation Index section with new TC→test method mappings
- For TDD-first: map to expected test method names (will be created by
)/integration-test - Update
with new TC entries in correct priority tierPRIORITY-INDEX.md
Skip this phase if user says "skip dashboard" or if no
docs/test-specs/ file exists for the module.
Phase 6: Next Step Suggestion
Based on mode, suggest via
AskUserQuestion:
TDD-first:
1. "/integration-test — Generate test stubs from these TCs (Recommended)" 2. "/plan — Plan the feature implementation" 3. "Done for now — I'll implement later"
Implement-first:
1. "/integration-test — Generate integration tests (Recommended)" 2. "/workflow-review-changes — Review all changes" 3. "Done for now"
Update (post-change/PR):
1. "/integration-test — Generate/update tests for changed TCs (Recommended)" 2. "/test — Run existing tests to verify coverage" 3. "/test-specs-docs — Sync dashboard with updated TCs" 4. "Done for now"
Sync:
1. "/test-specs-docs — Sync dashboard after reconciliation (Recommended)" 2. "/integration-test — Generate tests for any TCs missing test coverage" 3. "Done for now"
From-integration-tests:
1. "/test-specs-docs — Sync dashboard with newly documented TCs (Recommended)" 2. "/test — Run tests to verify all documented TCs pass" 3. "Done for now"
Anti-Patterns
- ❌ Writing TCs to
as the primary destination (use feature docs Section 15)docs/test-specs/ - ❌ Using
orTC-{SVC}-{NNN}
format (use unifiedTC-{SVC}-{FEATURE}-{NNN}
)TC-{FEATURE}-{NNN} - ❌ Generating TCs without reading existing Section 15 (causes ID collisions)
- ❌ Skipping the interactive review step (user must approve TC list)
- ❌ Writing TCs without Evidence field (every TC needs it, even if
)TBD
See Also
— Heavyweight test planning and investigation (use BEFORE this skill for complex features)test-spec
— Dashboard sync skill (aggregates TCs from feature docs totest-specs-docs
)docs/test-specs/
— Integration test code generator (use AFTER this skill to generate test stubs)integration-test
— Feature doc creator (creates the Section 15 that this skill populates)feature-docs
— PBI refinement (feeds acceptance criteria into this skill's TDD-first mode)refine
Workflow Recommendation
MANDATORY IMPORTANT MUST ATTENTION — NO EXCEPTIONS: If you are NOT already in a workflow, you MUST ATTENTION use
to ask the user. Do NOT judge task complexity or decide this is "simple enough to skip" — the user decides whether to use a workflow, not you:AskUserQuestion
- Activate
workflow (Recommended) — tdd-spec → tdd-spec-review → quality-gatepbi-to-tests- Execute
directly — run this skill standalone/tdd-spec
Next Steps
MANDATORY IMPORTANT MUST ATTENTION — NO EXCEPTIONS after completing this skill, you MUST ATTENTION use
AskUserQuestion to present these options. Do NOT skip because the task seems "simple" or "obvious" — the user decides:
- "/integration-test (Recommended)" — Generate integration test code from specs
- "/test" — Run tests to verify implementation
- "Skip, continue manually" — user decides
Closing Reminders
MANDATORY IMPORTANT MUST ATTENTION break work into small todo tasks using
TaskCreate BEFORE starting.
MANDATORY IMPORTANT MUST ATTENTION validate decisions with user via AskUserQuestion — never auto-decide.
MANDATORY IMPORTANT MUST ATTENTION add a final review todo task to verify work quality.
MANDATORY IMPORTANT MUST ATTENTION READ the following files before starting:
<!-- SYNC:rationalization-prevention:reminder -->
- IMPORTANT MUST ATTENTION never skip steps via "too simple" or "already searched" evasions. Plan anyway, test first, show grep evidence. <!-- /SYNC:rationalization-prevention:reminder --> <!-- SYNC:evidence-based-reasoning:reminder -->
- IMPORTANT MUST ATTENTION cite
evidence for every claim. Confidence >80% to act, <60% do NOT recommend. <!-- /SYNC:evidence-based-reasoning:reminder --> <!-- SYNC:cross-cutting-quality:reminder -->file:line - IMPORTANT MUST ATTENTION check error handling, logging, security, performance, and observability across changed files. <!-- /SYNC:cross-cutting-quality:reminder --> <!-- SYNC:ui-system-context:reminder -->
- IMPORTANT MUST ATTENTION read frontend-patterns-reference, scss-styling-guide, design-system/README before any UI change. <!-- /SYNC:ui-system-context:reminder --> <!-- SYNC:critical-thinking-mindset:reminder -->
- MUST ATTENTION apply critical thinking — every claim needs traced proof, confidence >80% to act. Anti-hallucination: never present guess as fact. <!-- /SYNC:critical-thinking-mindset:reminder --> <!-- SYNC:ai-mistake-prevention:reminder -->
- MUST ATTENTION apply AI mistake prevention — holistic-first debugging, fix at responsible layer, surface ambiguity before coding, re-read files after compaction. <!-- /SYNC:ai-mistake-prevention:reminder -->