| name | seed-test-data |
| version | 2.1.0 |
| description | [Dev Data] Use when you need to implement or enhance test data seeders that simulate QC happy-path scenarios via application-layer commands. |
| allowed-tools | Read, Write, Edit, Bash, Grep, Glob, TaskCreate, Agent |
[BLOCKING] Execute skill steps in declared order. NEVER skip, reorder, or merge steps without explicit user approval.
[BLOCKING] Before each step or sub-skill call, update task tracking: set in_progress when step starts, set completed when step ends.
[BLOCKING] Every completed/skipped step MUST include brief evidence or explicit skip reason.
[BLOCKING] If Task tools are unavailable, create and maintain an equivalent step-by-step plan tracker with the same status transitions.
Quick Summary
Goal: Implement or enhance test data seeders that create realistic, idempotent, valid test data through application-layer commands (NEVER direct DB writes) โ simulating QC happy-path scenarios without corrupting domain state.
Summary:
- Seeders orchestrate the real app pipeline: invoke application-layer commands (which own validation, domain logic, and event side-effects) โ never repo/DB inserts for domain entities, never duplicate command logic in the seeder.
- Four non-negotiable gates in order: (1) environment gate as the FIRST check, (2) count-before-seed idempotency, (3) loop from
existing_count to target_count (never 0), (4) scoped DI per iteration โ a shared scope silently corrupts the DbContext/session.
- Discover the project's seeder base class, env gate key, and count config key in Step 1 with
file:line evidence; read the count multiplier from config and never hardcode it (zero โ no-op).
- Always pre-read
docs/project-reference/seed-test-data-reference.md + project-config Data Seeders group, then close with a fresh zero-memory code-reviewer round; re-review fully only after a validated fix.
Workflow:
- Phase 0 โ Detect seeder task type (new / enhance / fix)
- Step 1 โ Discover project seeder patterns, env gate key, count key
- Step 2 โ Analyze feature scope + application commands
- Step 3 โ Find or create seeder file
- Step 4 โ Implement using language-agnostic algorithm
- Step 5 โ Validate against universal rules
- Review โ Fresh sub-agent review round
Key Rules:
- MUST ATTENTION read
docs/project-reference/seed-test-data-reference.md and docs/project-config.json (Data Seeders context group) before writing any seeder changes
- NEVER call repository/DB directly for domain data โ use application-layer commands
- NEVER duplicate command logic โ seeder orchestrates, commands own validation
- ALWAYS gate by environment first; ALWAYS check count before seeding
- ALWAYS read count multiplier from config (NEVER hardcode)
- ALWAYS loop from
existing_count to target_count for restart-safety
Phase 0: Detect Seeder Task Type
Before any other step, classify the request:
| Task Type | Detection | Action |
|---|
| New seeder | No existing seeder for feature area | Create following discovered base class pattern |
| Enhance existing | Seeder exists, needs new scenarios | Read existing seeder, add without breaking |
| Fix broken | Seeder fails env gate / idempotency / DI scope | Diagnose via Universal Rules, fix at root |
| Unknown | Request ambiguous | Ask user โ NEVER assume |
rg "{Feature}Seeder|{Feature}SeedData|{Feature}TestData" {configured-source-roots} -l
Universal Seed Data Rules
- Environment Gate โ First check in seeder. Dev/enabled-config only. NEVER production.
- Command-Based โ Calls application commands via full pipeline. Simulates QC manual testing. NEVER direct DB/repo writes for domain entities.
- No Duplicate Logic โ Seeder provides realistic inputs. Commands own validation, domain logic, event side-effects.
- Idempotency โ Check existing count โ calculate remaining โ seed only difference. Running N times converges to target.
- Count-Configurable โ Reads project config key (discovered Step 1). NEVER hardcode count.
- Restart-Safe โ Idempotency handles restarts: existing count found โ seeds only missing remainder.
- Spec-Consistent (Spec-Loop Discipline โ tailored) โ Seeders are orchestration, NOT business logic, so property/metamorphic generation and the MUTATION-SCORE gate are N/A here โ do not force them. Apply the dual-feedback half: every seeded scenario MUST stay consistent with the ยง5 invariants (commands own validation; a seeder that produces state violating an invariant is a bug, not a fixture). If a seeder encodes a domain rule โ a required precondition, a status/relationship the scenario assumes, a business default โ that rule belongs in the spec, not silently in the seeder: feed it into BOTH the spec (the rule) AND, where it is testable, the tests โ never a seeder-only fix.
Protocol
Step 1: Discover Seeder Patterns
Search for project seeder conventions:
rg "{configured-seeder-interface-or-base-patterns}|seeder|SeedData|DataSeed" {configured-source-roots} -l
Record with file:line evidence:
- Seeder base class / interface
- Seeder registration mechanism (DI, module, startup hook)
- Environment gate method/key name
- Count multiplier config key name
Step 1.5: Verify Dev Config Keys
Confirm dev config has both env gate key and count key. If absent, add following project's dev config convention. โ why: missing keys silently disable the gate or count, producing no-op or unbounded seeding.
Step 2: Feature Scope Analysis
Identify before writing any code:
- Feature area โ domain entity/aggregate being seeded
- Application commands โ
rg "{Feature}.*Command|{configured-command-handler-patterns}" {configured-source-roots} -l
- Dependencies โ data must exist (users, orgs, prerequisite records)
- Scenarios โ 3โ5 realistic variations (standard, boundary, multi-actor)
- Target count โ clarify: 1 scenario or N repetitions per scenario
Step 3: Find or Create Seeder
rg "{Feature}TestSeeder|{Feature}SeedingHelper|{Feature}TestDataSeeder" {configured-source-roots} -l
- Exists โ enhance with new scenarios, do NOT break existing ones
- Absent โ create following discovered base class pattern
Step 4: Implement
Algorithm (language-agnostic):
seeder():
if not is_development_environment(): return
if not seed_enabled_in_config(): return
target = config.get("SeedCount")
if target <= 0: return
existing = count_by_seeder_marker()
if existing >= target: return
for i from existing to target:
call_application_command(build_scenario_input(i))
Seeder marker โ stable predicate identifying seeded vs user data:
- Email prefix, created-by field, name prefix, or dedicated boolean flag
- MUST be deterministic across restarts
Step 5: Validate
MUST ATTENTION verify all before complete:
- MUST ATTENTION environment gate is FIRST check โ
file:line evidence required
- MUST ATTENTION count-before-seed idempotency gate present โ
file:line evidence
- MUST ATTENTION loop starts at
existing_count, not 0 โ file:line evidence
- MUST ATTENTION only application-layer commands used for domain entities โ NEVER repo/DB
- MUST ATTENTION no business logic or validation duplicated in seeder
- MUST ATTENTION seeder registered via project DI mechanism โ
file:line evidence
- MUST ATTENTION count config key read correctly (zero โ no-op, NEVER hardcoded)
- MUST ATTENTION scoped DI per iteration โ shared scope = DbContext/session corruption
Sub-Agent Routing
| Task | Sub-Agent | When |
|---|
| Discover seeders + commands across large codebase | general-purpose | Steps 1-2 |
| Review seeder compliance | code-reviewer | Round 1 post-implementation |
| Seeder handles credentials/PII | security-auditor | Security-sensitive patterns |
| Seeder runs 1000+ records | performance-optimizer | Performance-intensive |
All sub-agent prompts MUST include:
Graph DB active. After grep finds key files, run:
python .claude/scripts/code_graph trace <file> --direction both --json
Pattern: grep โ trace โ grep verify.
Anti-Patterns
| Anti-Pattern | Correct |
|---|
| Direct repo insert for domain entities | Call application command |
| Seeder validates business rules | Command owns validation; seeder provides valid inputs |
| No idempotency check | Check count first; seed only remaining |
Hardcoded count (for i in 0..10) | Read count from config key (discovered Step 1) |
| No environment gate | Check project env gate key first |
| Shared DI scope across loop iterations | Use project's scoped DI per iteration (prevents DbContext corruption) |
| Batch-all-then-write sub-agent findings | Persist findings per file; NEVER batch at end |
Review Loop
Round 1: After implementation, spawn fresh code-reviewer sub-agent with zero memory of implementation:
Review seeder at [file:path]. Verify with file:line evidence for each:
1. Environment gate is FIRST check
2. Idempotency: count-before-seed pattern present
3. Loop starts at existing_count not 0
4. Zero application-layer command bypasses (direct repo/DB = FAIL)
5. No hardcoded count โ config key read
6. Scoped DI per iteration
Report: PASS or FAIL with file:line for each finding.
Fix loop: If FAIL โ validate findings โ fix validated findings โ restart full review from first phase. When restarted review uses sub-agents, NEVER reuse them across rounds. If same blocker repeats across 3 full invocations with no progress, escalate to user.
NEVER fix unvalidated findings. Do not spawn a fresh sub-agent only to re-review known findings before validation/fix.
Workflow Recommendation
MUST ATTENTION โ NOT IN WORKFLOW YET: Use AskUserQuestion:
- Activate
workflow-seed-test-data (Recommended) โ scout โ investigate โ seed-test-data โ review-changes โ code-simplifier โ docs-update
- Execute
/seed-test-data directly โ run this skill standalone
Next Steps
MUST ATTENTION after completing: use AskUserQuestion โ do NOT skip:
- "/workflow-review-changes (Recommended)" โ review all changes before commit
- "/integration-test" โ write tests verifying idempotency and count compliance
- "Skip, continue manually" โ user decides
[IMPORTANT] TaskCreate for ALL tasks BEFORE starting. For simple tasks, ask user whether to skip.
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.
Understand Code First โ HARD-GATE: Do NOT write, plan, or fix until you READ existing code.
- Search 3+ similar patterns (
grep/glob) โ cite file:line evidence
- Read existing files in target area โ understand structure, base classes, conventions
- Run
python .claude/scripts/code_graph trace <file> --direction both --json when .code-graph/graph.db exists
- Map dependencies via
connections or callers_of โ know what depends on your target
- Write investigation to
.ai/workspace/analysis/ for non-trivial tasks (3+ files)
- Re-read analysis file before implementing โ never work from memory alone. โ why: long context drifts from the file; the file is ground truth
- NEVER invent new patterns when existing ones work โ match exactly or document deviation. โ why: divergent patterns fragment the codebase and slow every future reader
BLOCKED until: - [ ] Read target files - [ ] Grep 3+ patterns - [ ] Graph trace (if graph.db exists) - [ ] Assumptions verified with evidence
Evidence-Based Reasoning โ Speculation is FORBIDDEN. Every claim needs proof.
- Cite
file:line, grep results, or framework docs for EVERY claim
- 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:line) - [ ] Grep 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: [...]."
AI Mistake Prevention โ Failure modes to avoid on every task:
Re-read files after context changes. Context compaction, resume, or long-running work can make memory stale; verify current files before acting.
Verify generated content against source evidence. AI hallucinates APIs, names, claims, and document facts. Check the relevant source before documenting or referencing.
Check downstream references before deleting or renaming. Removing an artifact can stale docs, generated mirrors, configs, and callers; map references first.
Trace the full impact chain after edits. Changing a definition can miss derived outputs and consumers. Follow the affected chain before declaring done.
Verify ALL affected outputs, not just the first. One green check is not all green checks; validate every output surface the change can affect.
Assume existing values are intentional โ ask WHY before changing. Before changing a constant, limit, flag, wording, or pattern, read nearby context and history.
Surface ambiguity before acting โ don't pick silently. Multiple valid interpretations require an explicit question or stated assumption with risk.
Keep shared guidance role-relevant. Universal guidance must help every receiving skill or agent; code-specific obligations belong only in code-specific protocols.
IMPORTANT MUST ATTENTION search 3+ existing patterns and read code BEFORE writing any seeder.
MUST ATTENTION cite file:line for every claim; declare confidence; "I don't have enough evidence" is valid output.
MUST ATTENTION apply critical + sequential thinking โ every claim needs appropriate traced evidence (file:line for repo/code claims; source URL or artifact section for research, product, content, and docs claims); confidence >80% to act, <60% DO NOT recommend. Anti-hallucination: never present guess as fact, admit uncertainty freely, cross-reference independently, stay skeptical of own confidence.
MUST ATTENTION apply AI mistake prevention โ verify generated content against evidence, trace downstream references before deleting or renaming, verify all affected outputs, re-read files after context loss, and surface ambiguity before acting.
Prompt-Enhance Closing Anchors
IMPORTANT MUST ATTENTION follow declared step order for this skill; NEVER skip, reorder, or merge steps without explicit user approval
IMPORTANT MUST ATTENTION for every step/sub-skill call: set in_progress before execution, set completed after execution
IMPORTANT MUST ATTENTION every skipped step MUST include explicit reason; every completed step MUST include concise evidence
IMPORTANT MUST ATTENTION if Task tools unavailable, maintain an equivalent step-by-step plan tracker with synchronized statuses
Closing Reminders
IMPORTANT MUST ATTENTION Goal: Implement/enhance seeders creating realistic, idempotent, valid test data through application-layer commands (NEVER direct DB writes) โ simulate QC happy-path scenarios without corrupting domain state.
Protocols in force (concise digest of the SYNC/shared blocks this skill carries):
- Critical Thinking: MUST ATTENTION apply critical+sequential thinking; traced proof, confidence >80%.
- Understand Code First: ALWAYS search 3+ patterns and read code before writing.
- Evidence: MUST ATTENTION cite
file:line per claim; declare confidence; "insufficient evidence" valid.
- AI Mistake Prevention: verify generated content against evidence, trace downstream references, verify all affected outputs, re-read after context loss, surface ambiguity.
IMPORTANT MUST ATTENTION NEVER call repo/DB directly for domain data โ use application-layer commands โ why: bypassing the command pipeline skips validation, domain logic, and event side-effects, producing invalid state that passes silently
IMPORTANT MUST ATTENTION ALWAYS gate by environment FIRST, then ALWAYS check count before seeding โ why: env gate prevents prod corruption; count gate is the idempotency guarantee
IMPORTANT MUST ATTENTION loop from existing_count to target_count โ NEVER from 0 โ why: looping from 0 re-seeds on every restart and breaks restart-safety
IMPORTANT MUST ATTENTION scoped DI per iteration โ shared DI scope = silent DbContext/session corruption
IMPORTANT MUST ATTENTION ALWAYS read count multiplier from the discovered config key โ NEVER hardcode (zero โ no-op, never unbounded loop)
IMPORTANT MUST ATTENTION NEVER duplicate command logic in the seeder โ seeder provides realistic inputs, commands own validation/domain/events
IMPORTANT MUST ATTENTION every seeded scenario MUST stay consistent with the ยง5 universal invariants; if a seeder encodes a domain rule (precondition, status, default) feed it into the spec โ and tests where testable โ NEVER a seeder-only fix โ why: a hidden rule in a seeder drifts from the spec and breaks future readers
IMPORTANT MUST ATTENTION Evidence gate: cite file:line for the env gate, count gate, loop start, DI scope, and seeder registration โ confidence >80% to act, <60% DO NOT recommend; "Insufficient evidence" is valid output
IMPORTANT MUST ATTENTION search 3+ existing seeder patterns and READ them before writing โ match the discovered base class / env-gate / count-key conventions exactly; verify the copied pattern shares the same preconditions (base class, scope, lifetime) before reuse
IMPORTANT MUST ATTENTION read docs/project-reference/seed-test-data-reference.md + docs/project-config.json (Data Seeders group) BEFORE any seeder change โ project conventions override generic defaults
IMPORTANT MUST ATTENTION TaskCreate โ break all work into tasks BEFORE starting; transition one task at a time, evidence per completed step
IMPORTANT MUST ATTENTION close with a fresh zero-memory code-reviewer round; full re-review is required ONLY after a validated fix cycle โ a clean review pass ENDS the review; NEVER fix unvalidated findings
Anti-Rationalization:
| Evasion | Rebuttal |
|---|
| "Simple seeder, skip review loop" | Idempotency bugs are silent. Run Round 1 always. |
| "Already know the base class" | Show file:line. No proof = no knowledge. |
| "Environment gate is obvious" | Verify it's FIRST check with file:line evidence. |
| "Just hardcode count for now" | NEVER โ config key required. Find it in Step 1. |
| "Seeder can validate this quickly" | NEVER duplicate logic โ command owns validation; seeder feeds inputs. |
| "Skip the reference docs, I know seeders" | Project conventions override generic patterns. Read them first. |
| "No graph.db, skip trace" | Use grep-only trace. Still run 3+ pattern search. |
| "Existing scenarios look fine, skip enhance" | Read all scenarios; enhancement may conflict โ verify first. |
[TASK-PLANNING] Before acting, break task into small todo tasks using TaskCreate.
IMPORTANT MUST ATTENTION NEVER direct repo/DB writes for domain data ยท ALWAYS env-gate FIRST then count-gate ยท file:line evidence for every gate (confidence >80%).