Instalar com Codex ou Claude Copie este prompt, cole no Codex, Claude ou outro assistente e deixe que ele revise a página da skill e instale para você.
Um comando direto ignora o prompt de revisão. Verifique a origem antes de executá-lo.
[Testing] Use when you need to generate or review integration tests.
Codex compatibility note:
Invoke repository skills with $skill-name in Codex; this mirrored copy rewrites legacy Claude /skill-name references.
Task tracker mandate: BEFORE executing any workflow or skill step, create/update task tracking for all steps and keep it synchronized as progress changes.
User-question prompts mean to ask the user directly in Codex.
Ignore Claude-specific mode-switch instructions when they appear.
Strict execution contract: when a user explicitly invokes a skill, execute that skill protocol as written.
Subagent authorization: when a skill is user-invoked or AI-detected and its protocol requires subagents, that skill activation authorizes use of the required spawn_agent subagent(s) for that task.
Do not skip, reorder, or merge protocol steps unless the user explicitly approves the deviation first.
For workflow skills, execute each listed child-skill step explicitly and report step-by-step evidence.
If a required step/tool cannot run in this environment, stop and ask the user before adapting.
Codex Project-Reference Loading (No Hooks)
Codex uses static project-reference loading instead of runtime-injected project docs.
When coding, planning, debugging, testing, or reviewing, open project docs explicitly using this routing.
Always read:
docs/project-config.json (project-specific paths, commands, modules, and workflow/test settings)
docs/project-reference/docs-index-reference.md (routes to the full docs/project-reference/* catalog)
docs/project-reference/lessons.md (always-on guardrails and anti-patterns)
If , the docs index, , , , or any task-required reference doc is missing or stale, auto-run or the narrow setup route (, , , , ) before ordinary project-specific work. If Codex mirrors or are missing/stale, ask the user to run ; do not auto-run it.
Spec authoring, docs/specs/ pathing, or TC format: feature-spec-reference.md, spec-system-reference.md, spec-principles.md
Behavior/public-contract changes or spec-test-code sync: workflow-spec-test-code-cycle-reference.md plus the spec docs above
Derived spec indexes/ERDs/reimplementation guides: spec-system-reference.md and source Feature Specs under docs/specs/
Integration test implementation/review: integration-test-reference.md
E2E test implementation/review: e2e-test-reference.md
Code review/audit work: code-review-rules.md plus domain docs above based on changed files
Do not read all docs blindly. Start from docs-index-reference.md, then open only relevant files for the task.
[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: Generate/review integration tests using real DI (no mocks) across 5 modes (from-changes · from-prompt · review · diagnose · verify-traceability) that exercise real production paths and assert specific DB field values — so every test protects a traceable business behavior (TC), survives repeated runs without reset, and fails only when the protected intent actually breaks.
Summary:
Three things make or break a test here: read handler/entity/event source first and assert specific changed fields (never smoke/DI-resolution-only), wrap EVERY DB assertion in async polling (not just async handlers), and drive state through real command/query/seeder paths — never direct repository writes that fabricate invalid state.
TC traceability is the spine: each test method carries a TC-{FEATURE}-{NNN} test-spec annotation; one business TC maps to MANY tests (1:N, integration + unit), so cover with as many tests as needed — never split a TC to force 1:1, and auto-create a TC in feature-doc Section 8 only for genuinely uncovered business behavior.
Always search existing tests in the SAME service and read references/integration-test-patterns.md before writing; match local conventions (collection, base class, helpers, unique-name generators) and organize files by domain feature, never by Queries//Commands/ CQRS type.
Done means repeatable, not green-once: the suite must pass 3 consecutive $integration-test-verify runs WITHOUT a DB reset; the in-skill review/verify modes are lightweight inline passes, distinct from the heavier standalone $integration-test-review and $integration-test-verify skills.
NEVER write smoke-only tests — read handler/entity/event source first, assert specific field values
ALWAYS wrap ALL DB assertions in async polling — no exceptions, not just async handlers
NEVER create invalid test state by direct repository writes; use real use-case paths (commands, queries, production consumers/messages) or valid seeded fixtures
MUST ATTENTION search existing patterns FIRST before generating any test
MUST ATTENTION READ references/integration-test-patterns.md before writing
Organize by domain feature NEVER by CQRS type — NEVER create Queries/ or Commands/ folders
Every test method MUST have TC annotation — auto-create in Section 8 if missing
Minimum 3 tests per command
NEVER mark done until the relevant suite passes 3 consecutive $integration-test-verify runs without DB reset
Prerequisites — MUST ATTENTION READ before executing:
references/integration-test-patterns.md — canonical test templates: collection attributes, base class usage, TC annotation format, async polling helpers, unique name generators, DB assertion patterns. Read before writing ANY test.
docs/specs/ — existing TCs by module: read to verify test-to-spec traceability and get TC IDs before generating.
references/integration-test-patterns.md — canonical test templates (MUST READ before writing any test)
docs/specs/ — existing TCs by module (read before generating tests; verify test-to-spec traceability)
CRITICAL: Search existing patterns FIRST. Before generating ANY test, grep existing integration test files in same service. Read ≥1 existing test file to match conventions (namespace, usings, collection name, base class, helper usage). NEVER generate tests contradicting established codebase patterns.
CRITICAL: NO Smoke/Fake/Useless Tests. Every test MUST execute actual commands/handlers and verify DB data state. NO DI-resolution-only tests. NO exception-check-only tests. Before writing assertions: READ handler/entity/event source — understand WHAT fields change, WHAT entities created/updated/deleted, WHAT event handlers fire. Assert specific field values.
CRITICAL: Async Polling for ALL Data Assertions. ALWAYS wrap data state assertions in async polling/retry helper. DEFAULT for ALL data verification — not just async handlers. Data persistence may be delayed by event handlers, message bus consumers, background jobs, DB write latency. Rule: If asserting data in DB → use async polling. No exceptions.
For test specifications and test case generation from PBIs, use $spec [mode=tests] skill instead.
Spec-Loop Discipline (property + mutation bar). Where a rule is universal — a [HARD] §4 rule or a §5 invariant that holds for ALL inputs, not just one example — generate a property/metamorphic test (see references/integration-test-patterns.md → Pattern 9) plus a boundary counter-case, and trace each to a §8 Invariant/Property TC (not just an example-scenario TC). The assertion-quality bar is MUTATION-KILL, not line-coverage %: a mutant that survives on the covered core-logic = a missing invariant → write the killing test. (Example-only scenarios stay valid for non-universal behaviors; this is additive for the universal ones.)
External Memory: Complex/lengthy work → write findings to plans/reports/ — prevents context loss.
Evidence Gate: MANDATORY IMPORTANT MUST ATTENTION — every claim requires file:line proof or traced evidence with confidence percentage (>80% act, <80% verify first).
First Principle — Easy to Change
The success metric of every coding decision is future change cost.
DRY, SRP, abstraction, design patterns, naming, layering, tests — every
technique exists to serve one goal: making the next change cheaper.
When evaluating code, a refactor, a test, or an abstraction, ask:
does this make the next change cheaper or more expensive?
Reject "best practices" that raise change cost (premature abstraction,
speculative generality, leaky indirection, ceremony without payoff).
Name the real enemies in findings: coupling, hidden state, duplicated
knowledge, unclear intent, irreversible decisions exposed too early.
A simpler design that is easy to change beats a sophisticated design that
isn't.
Apply this lens before invoking any specific rule, pattern, or checklist
below — if a downstream rule would raise change cost, this principle wins.
Project Pattern Discovery
Before implementation, search codebase for patterns:
Look for: existing test projects, collection definitions, service-specific base classes
MANDATORY IMPORTANT MUST ATTENTION plan task to READ integration-test-reference.md for project-specific patterns and code examples. If not found, continue with search-based discovery.
Workflow:
Detect mode — See Mode Detection below
Find targets — Identify test/command/query files
Gather context — Read relevant files for detected mode
MUST ATTENTION search existing test patterns in same service BEFORE generating
MUST ATTENTION READ references/integration-test-patterns.md before writing any test
Organize by domain feature, NEVER by type — command + query tests for same domain → same folder (e.g., Orders/OrderCommandIntegrationTests.*). NEVER create Queries/ or Commands/ folder.
Use project's unique name generator for ALL string test data
Use project's entity assertion helpers for DB verification with async polling
CRITICAL MUST ATTENTION: Test setup MUST mirror real workflows. Do not create or edit domain data through repositories when a command/query/seeder path exists; invalid shortcut data is a test bug.
CRITICAL MUST ATTENTION: ALWAYS wrap ALL DB assertions in async polling/retry — DEFAULT for ALL assertions, not just async handlers. If asserting data in DB → use async polling. No exceptions.
CRITICAL MUST ATTENTION: Before writing assertions, READ handler/entity/event source. Understand WHAT fields change, WHAT entities created/updated/deleted, WHAT event handlers fire. Smoke-only FORBIDDEN unless side effect truly unobservable.
CRITICAL MUST ATTENTION: Verification requires 3 consecutive successful runs of the relevant integration suite/project without resetting data. One green run proves only the current run, not repeatability.
Minimum 3 test methods: happy path, validation failure, DB state check
Authorization tests: Multiple user contexts — authorized succeeds AND unauthorized rejected
Every test method MUST have // TC-{FEATURE}-{NNN}: Description comment + test-spec annotation — before method, outside body. Many test methods MAY carry the same TC (one business TC → many tests across components/services); the test-spec annotation is the join key, so cover a TC with as many technical tests as the implementation needs without inventing extra TCs.
No TC in feature docs → auto-create in Section 8 before generating test (auto-create a TC only for genuinely uncovered business behavior — never create a TC just to mirror a new test method when an existing TC already covers that behavior)
For comprehensive spec generation before coding → $spec [mode=tests] first
Mandatory Task Ordering (MUST ATTENTION FOLLOW)
ALWAYS create and execute tasks in this exact order:
FIRST: Verify/upsert test specs in feature docs
Read feature doc Section 8 (docs/specs/{App}/README.{Feature}.md) for target domain
For each test case: verify matching TC-{FEATURE}-{NNN} exists
TC MISSING → create entry in Section 8 with Priority, Status, GIVEN/WHEN/THEN, Evidence
TC INCORRECT → update to reflect current behavior
Output: TC mapping list (TC code → test method name(s)) — one TC may map to many test methods (across components/services); the mapping is 1 TC : N tests, joined by the TestSpec annotation
MIDDLE: Implement integration tests
Generate test files using TC mapping from task 1
Each test method gets the TC annotation before it (outside the method body) using the configured test framework's attribute/decorator/tag/marker syntax.
Follow existing patterns from project's test base classes
FINAL: Verify traceability (cardinality: 1 TC : N tests)
Grep test-spec annotations across all test projects/suites for the stack — integration and unit (a TC may be covered by tests in either — grep only the integration project and unit-only-covered TCs falsely look uncovered)
Grep all TC-{FEATURE}-{NNN} in feature doc Section 8 / specs doc
Verify: every test method → exactly one doc TC (its TestSpec annotation); every doc TC → ≥1 covering test method. One TC may be covered by many test methods (integration + unit, across components/services) — that is the expected one-to-many shape. NEVER require one test per TC, and NEVER split/technicalize a business TC to make tests map 1:1 (breaks the spec's business/user-story orientation, M1/M5 — see tc-format.md → TC ↔ Test Code Cardinality).
Flag orphans: tests whose TestSpec TC is absent from §8; doc TCs with zero covering tests. (Many tests sharing one TC is NOT an orphan and NOT a duplicate.)
Update the IntegrationTest field in feature doc TCs with the covering tests — {File}::{MethodName} comma-separated on one line, or a test-filter expression when the set is large (the field is representative; the annotation in code is authoritative). The covering set MAY include unit tests, not only integration tests.
Module Abbreviation Registry
Module
Abbreviation
Test Folder
Order Management
OM
Orders/
Inventory
INV
Inventory/
User Profiles
UP
UserProfiles/
Notification Management
NM
Notifications/
Report Generation
RG
Reports/
Feedback
FB
Feedback/
Background Jobs
BJ
—
TC Code Numbering Rules
Creating new TC-{FEATURE}-{NNN} codes:
Check feature doc first — docs/specs/{App}/README.{Feature}.md has existing codes. New codes must not collide.
Args = command/query name (e.g., "$integration-test CreateOrderCommand")
→ FROM-PROMPT mode: generate tests for the specified command/query
No args (e.g., "$integration-test")
→ FROM-CHANGES mode: detect changed command/query files from git
Args = "review" (e.g., "$integration-test review Orders")
→ REVIEW mode: audit existing test quality, find flaky patterns, check best practices
Args = "diagnose" (e.g., "$integration-test diagnose OrderCommandIntegrationTests")
→ DIAGNOSE mode: analyze why tests fail — determine test bug vs code bug
Args = "verify" (e.g., "$integration-test verify {Service}")
→ VERIFY-TRACEABILITY mode: check test code matches specs and feature docs
Modes vs. sibling skills (name-collision note). The review and verifymodes above are lightweight branches inside this skill — quick, inline audits run during generation. They are NOT the same as the standalone skills $integration-test-review (deep test-quality review) and $integration-test-verify (full spec-traceability verification), which are separate, heavier workflow steps. When the refactor workflow sequences $integration-test → $integration-test-review → $integration-test-verify, those are the standalone skills, not these in-skill modes. Use a mode for a fast pass mid-generation; invoke the sibling skill for a thorough, standalone gate.
Filter for command/query files using project naming conventions (e.g., *Command.*, *Query.*). Path patterns from docs/project-config.json → modules or backendServices. Extract service from path:
Command/query file — extract: class name, result type, DTO properties, entity type
Existing test files in same service — Glob {Service}.IntegrationTests/**/*IntegrationTests.*, read ≥1 for conventions (collection/suite name, test annotations, namespace/imports, base class)
Service integration test base class — grep: class.*ServiceIntegrationTestBase
Build mapping: test case description → TC code (e.g., "create valid order" → TC-OM-001).
No TC exists → CREATE IT in Section 8 before generating test. NOT optional.
TC outdated/incorrect → UPDATE IT first.
Section 8 missing → run $spec [mode=tests] first.
Step 3: Generate Test File
File path:{project-test-dir}/{Service}.IntegrationTests/{Domain}/{CommandName}IntegrationTests{ext} (adapt path/extension per docs/project-config.json → integrationTestVerify.testProjectPattern)
Folder = domain feature.{Domain} = business domain (Orders, Inventory, Notifications, UserProfiles), NOT CQRS type. Command and query tests for same domain live in same folder.
Structure: adapt file layout, imports, fixture setup, assertion style, and test markers from existing tests in the configured test project.
namespace {Service}.IntegrationTests.{Domain};
[Collection({Service}IntegrationTestCollection.Name)]
[Trait("Category", "Command")] // or "Query"
public class {CommandName}IntegrationTests : {Service}ServiceIntegrationTestBase
{
// Minimum 3 tests: happy path, validation failure, DB state verification
}
**Test method naming:** `{CommandName}_When{Condition}_Should{Expectation}`
**Required patterns per command type:**
| Command type | Required tests |
| ------------ | -------------------------------------------------- |
| Save/Create | Happy path + validation failure + DB state |
| Update | Create-then-update + verify updated fields in DB |
| Delete | Create-then-delete + `AssertEntityDeletedAsync` |
| Query | Filter returns results + pagination + empty result |
| **Owns a [HARD] §4 rule or §5 invariant** (orthogonal to the rows above — applies to the same command/query) | **+ Pattern 9 property/metamorphic test** tied to a §8 Invariant/Property TC: the example tests above guard fixed points; the property test guards the rule across its whole input domain (see `references/integration-test-patterns.md` → Pattern 9). FORCED, not optional — a `>`/`>=` flip on the invariant line must fail an assertion. |
> **[FORCED BRANCH — property apparatus]** Pattern 9 is not a "nice-to-have reference". For ANY command/query whose handler enforces a `[HARD]` §4 business rule or a §5 entity invariant, the example-based rows are NOT sufficient on their own — generate the Pattern 9 property test alongside them, carrying the `TestSpec` annotation of the §8 Invariant/Property TC (decade `071–079`). This is the test-side mirror of the spec-side invariant-coverage gate (`spec [mode=tests]` → property TC count ≥ count([HARD] BR) + count(§5 invariants)). Skipping it = a fakeable, over-fitted suite that passes while the rule can be broken across the unenumerated space.
## Step 4: Verify
Build test project via project's build tool (see `$integration-test-verify` for config-driven build).
MUST ATTENTION verify ALL of the following:
- Test collection/group attribute present with correct collection name
- Test category annotation present
- All string test data uses project's unique name generator
- User context created via project's user context factory
- DB assertions use project's entity assertion helpers with async polling
- No mocks — real DI only
- Every test method has `// TC-{FEATURE}-{NNN}: Description` comment + test-spec annotation
## Example Files to Study
Search codebase for existing integration test files:
```bash
find . -name "*IntegrationTests.*" -type f
find . -name "*IntegrationTestBase.*" -type f
find . -name "*IntegrationTestFixture.*" -type f
→ Analyzes failures, determines test bug vs code bug
Case: Verify test-spec traceability
$integration-test verify {Service}
→ Checks test code matches specs and feature docs bidirectionally
REVIEW Mode — Test Quality Audit
Mode = REVIEW: audit existing integration tests for quality, flaky patterns, best practices.
Sub-Agent Routing
Input type
Sub-agent
Why
Test file quality audit
integration-tester
Purpose-built for spec generation, TC traceability, and test patterns — catches integration-specific issues code-reviewer misses
Security-sensitive test data (PII, auth fixtures)
security-auditor
Detects PII leakage in test fixtures
Sub-Agent Type Override
MANDATORY: Integration test REVIEW mode spawns integration-tester sub-agent (agent_type: "integration-tester"), NOT code-reviewer.
Rationale:integration-tester specializes in test spec generation, TC traceability, CQRS test patterns, async-polling / eventual-consistency assertion correctness, and cross-service integration context — areas code-reviewer does not cover at depth.
Fresh Eyes Protocol: Run Round 1 inline. If findings are LOW confidence or contradictory → spawn fresh integration-tester sub-agent (zero memory of Round 1) for Round 2. Main agent reads report, NEVER filters findings. Max 2 rounds, then escalate.
Review Workflow
Find test files — Glob {Service}.IntegrationTests/{Domain}/**/*IntegrationTests.*
Read each test file — analyze for quality issues (persist findings after each file per SYNC:incremental-persistence)
Generate quality report — categorized findings with severity
Round 2 (if low confidence): Spawn fresh sub-agent with report path — NEVER re-examine with main context
Review Dimensions
Dimension 1: Reliability — Think: What causes intermittent failures?
MUST ATTENTION flag missing async polling — DB assertions after async handlers without an await-until-condition poll (the project's async-assertion helper) → WILL flake
MUST ATTENTION flag missing retry for eventual consistency — message bus / event handler / background job state without polling wrapper
MUST ATTENTION flag hardcoded delays — Thread.Sleep(), Task.Delay() instead of condition-based polling
MUST ATTENTION flag race conditions — tests modifying shared state without isolation (same entity ID, same user context)
MUST ATTENTION flag non-unique test data — hardcoded strings/IDs instead of unique generators
MUST ATTENTION flag time-dependent assertions — DateTime.Now without time abstraction
Dimension 2: Assertion Value — Think: Does the test actually verify anything?
MUST ATTENTION flag DI-resolution-only tests — smoke tests that just resolve services → HIGH severity
MUST ATTENTION flag exception-check-only tests — exception.Should().BeNull() alone → HIGH severity
MUST ATTENTION verify test reads handler/entity/event source and asserts specific field values
MUST ATTENTION verify minimum 3 tests per command (happy path, validation failure, DB state)
Dimension 3: Conventions — Think: Does test follow project patterns?
MUST ATTENTION verify collection/group attribute — correct collection name for shared fixture
MUST ATTENTION verify category annotation or equivalent test-category marker when the project uses one
MUST ATTENTION verify TC annotation — every test method has a TC code comment + the test-spec annotation
MUST ATTENTION verify no mocks — real DI only
MUST ATTENTION verify unique test data — all string data uses unique generators
MUST ATTENTION verify user context — via factory, not hardcoded
MUST ATTENTION verify DB assertions — uses entity assertion helpers, not raw DB queries
Dimension 4: Code Quality — Think: Maintainability and isolation?
MUST ATTENTION verify method naming — {Action}_When{Condition}_Should{Expectation}
MUST ATTENTION verify Arrange-Act-Assert — clear separation
MUST ATTENTION flag logic in tests — conditionals, loops, complex setup in test methods
MUST ATTENTION verify test independence — each test runs in isolation
Identify mismatches — Orphans, stale references, behavior drift
Classify mismatches — Which source is correct?
Report — Traceability matrix + recommended fixes
Mismatch Classification
Scenario
Likely Correct Source
Action
Test passes, spec describes different behavior
Adjudication required
Compare against canonical product/spec intent before changing anything
Test fails, spec describes expected behavior
Spec, unless spec intent is disproved
Update test to match intended spec behavior
Test exists, no spec
Adjudication required
Create spec from test only after confirming the test protects intent
Spec exists, no test
Spec
Generate test from spec
Test and spec agree, but code behaves differently
Spec, unless both are stale
Fix code or update spec+test after intent adjudication
Rule: Passing code or tests NEVER automatically outrank canonical product/spec intent. NEVER update spec, test, or code on a behavior-changing mismatch until it reaches adjudication-required status with explicit evidence. — why: a green test can encode a regression, so code agreement alone cannot ratify a spec change.
Verification Requirements
MUST ATTENTION verify ALL of the following:
Every test method has matching TC in feature doc Section 8
Every TC in Section 8 has matching test method (or marked Status: Untested)
TC descriptions in docs match what test actually validates
Evidence file paths in TCs point to current (not stale) code locations
Test annotations match TC IDs (no typos, no orphaned IDs)
Priority levels in docs match test categorization
docs/specs/ dashboard is in sync with feature doc Section 8
Orchestrator — calls spec [mode=sync] (Phase 4) with test traceability
Run for full doc sync after integration test files updated
Standalone Chain
When called outside a workflow, follow this chain to complete the integration test authoring cycle.
integration-test (you are here)
│
├─ PREREQUISITE: TCs must exist in feature doc Section 8
│ [REQUIRED] Verify: docs/specs/{Bucket}/README.{Feature}.md Section 8 has TC-{FEATURE}-{NNN} entries
│ If empty → run $spec [mode=tests] [CREATE mode] first
│
├─ [REQUIRED] → $integration-test-review
│ 7-gate quality audit: assertion value, data state, repeatability, domain logic, traceability, three-way sync, change coverage.
│ Never skip — Gate 6 (three-way sync) is the only place where spec/code/test conflicts surface,
│ and Gate 7 (change coverage) is the only place where untested changed behavior surfaces.
│
├─ [REQUIRED] → $integration-test-verify
│ Runs tests and reports pass/fail counts. Never mark complete without real runner output.
│
├─ [REQUIRED] → $spec [mode=sync]
│ Updates the §8 TCs' IntegrationTest: file::method traceability links.
│
├─ [RECOMMENDED] → $docs-update
│ Updates feature doc evidence fields and version history if test coverage changed materially.
│
└─ [RECOMMENDED] → $review-artifact --type=spec-tests
Re-run if integration-test-review (Gate 6) flagged TC issues requiring TC edits.
### Mode-Specific Chains
| Mode | Pre-step | Post-step |
|------|---------|-----------|
| from-changes | verify TCs updated (run $spec [mode=tests] UPDATE first) | $integration-test-review → /verify → /sync |
| from-prompt | confirm TC exists for target feature | $integration-test-review → /verify → /sync |
| review | N/A (read-only) | report findings → $spec [mode=tests] UPDATE if TCs need fixes |
| diagnose | run $test to see failures first | fix identified issue → re-run $integration-test-verify |
| verify-traceability | N/A (read-only) | if orphaned TCs: $spec [mode=tests] UPDATE → $integration-test [from-prompt] |
[IMPORTANT] task tracking — break ALL work into small tasks BEFORE starting. NEVER skip task creation.
Source/test drift check. For coding, fix, debug, investigation, test, or review work: when source behavior changes, inspect affected unit/integration/E2E tests and decide from evidence whether tests should change to match intended behavior or the source change is an unintended bug to fix. Do not write tests for migration code; schema/data migrations are one-time execution paths, not core application logic.
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.
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
Graph Impact Analysis — When .code-graph/graph.db exists, run blast-radius --json to detect ALL files affected by changes (7 edge types: CALLS, MESSAGE_BUS, API_ENDPOINT, TRIGGERS_EVENT, PRODUCES_EVENT, TRIGGERS_COMMAND_EVENT, INHERITS). Compute gap: impacted_files - changed_files = potentially stale files. Risk: <5 Low, 5-20 Medium, >20 High. Use trace --direction downstream for deep chains on high-impact files.
Infinitely Repeatable Tests — Tests MUST run N times without failure. Like manual QC — run the suite 100 times, each run just adds more data. Verification is only PASS after the relevant suite/project passes 3 consecutive runs without database reset.
Unique data per run: Use the project's unique ID generator for ALL entity IDs created in tests. NEVER hardcode IDs.
Additive only: Tests create data, never delete/reset. Prior test runs MUST NOT interfere with current run.
No schema rollback dependency: Tests work with current schema only. Never rely on schema rollback or migration reversals.
Idempotent seeders: Fixture-level seeders use create-if-missing pattern (check existence before insert). Test-level data uses unique IDs per execution.
No cleanup required: No teardown, no database reset between runs. Each test is isolated by unique seed data, not by cleanup.
Unique names/codes: When entities require unique names/codes, append a unique suffix using the project's ID generator.
Migration code excluded: Do not write tests for migration code. Schema/data migrations are one-time execution paths, not core application logic.
Red Flag Stop Conditions — STOP and escalate to user via ask the user directly when:
Confidence drops below 60% on any critical decision
Changes would affect >20 files (blast radius too large)
Sub-Agent Return Contract — When this skill spawns a sub-agent, the sub-agent MUST return ONLY this structure. Main agent reads only this summary — NEVER requests full sub-agent output inline.
Main agent reads Full report file ONLY when: (a) resolving a specific blocker, or (b) building a fix plan.
Sub-agent writes full report incrementally (per SYNC:incremental-persistence) — not held in memory.
Context budget — the return payload is a SUMMARY, not a transcript: ≤10 finding bullets, no raw file contents / full diffs / verbatim logs inline, no re-pasted source. Everything beyond the summary lives in the Full report on disk. A sub-agent that would exceed the summary shape MUST write the detail to its report and return only the pointer — the orchestrator's context is the scarce resource the whole map-reduce protects.
Sub-Agent Selection — Full routing contract: .claude/skills/shared/sub-agent-selection-guide.mdRule: Route specialized domains (architecture, security, performance, DB, E2E, integration-test, git) to the matching specialist agent (see guide above) — NEVER use code-reviewer for these. — why: code-reviewer lacks each domain's checklist, so specialized issues slip through.
Nested Task Expansion Contract — For workflow-step invocation, the [Workflow] ... row is only a parent container; the child skill still creates visible phase tasks.
Call the current task list first. If a matching active parent workflow row exists, set nested=true and record parentTaskId; otherwise run standalone.
Create one task per declared phase before phase work. When nested, prefix subjects [N.M] $skill-name — phase.
When nested, link the parent with TaskUpdate(parentTaskId, addBlockedBy: [childIds]).
Orchestrators must pre-expand a child skill's phase list and link the workflow row before invoking that child skill or sub-agent.
Mark exactly one child in_progress before work and completed immediately after evidence is written.
Complete the parent only after all child tasks are completed or explicitly cancelled with reason.
Blocked until: the current task list done, child phases created, parent linked when nested, first child marked in_progress.
Project Reference Docs Gate — Run after task-tracking bootstrap and before target/source file reads, grep, edits, or analysis. Project docs override generic framework assumptions.
Identify scope: file types, domain area, and operation.
Read every required doc. If docs/project-config.json, the docs index, lessons.md, CLAUDE.md, AGENTS.md, or any task-required reference doc is missing or stale, auto-run $project-init or the narrow lower-level route ($project-config, $docs-init, $scan-all, $scan --target=<key>, $claude-md-init) before ordinary project-specific work. If Codex mirrors or AGENTS.md are missing/stale, ask the user to run $sync-codex; do not auto-run it.
Before target work, state: Reference docs read: ... | Not applicable: ....
Task Tracking & External Report Persistence — Bootstrap this before execution; then run project-reference doc prefetch before target/source work.
Create a small task breakdown before target file reads, grep, edits, or analysis. On context loss, inspect the current task list first.
Mark one task in_progress before work and completed immediately after evidence; never batch transitions.
For plan/review work, create plans/reports/{skill}-{YYMMDD}-{HHmm}-{slug}.md before first finding.
Append findings after each file/section/decision and synthesize from the report file at the end.
Final output cites Full report: plans/reports/{filename}.
Blocked until: task breakdown exists, report path declared for plan/review work, first finding persisted before the next finding.
MANDATORY IMPORTANT MUST ATTENTION run graph trace when graph.db exists. Grep 3+ patterns, cite file:line.
MANDATORY IMPORTANT MUST ATTENTION cite file:line evidence for every claim. Confidence >80% to act, <60% = do NOT recommend.
MANDATORY IMPORTANT MUST ATTENTION run blast-radius when graph.db exists. Flag impacted files NOT in changeset as potentially stale.
MANDATORY IMPORTANT MUST ATTENTION STOP after 3 failed fix attempts. Report all attempts, ask user before continuing.
MANDATORY IMPORTANT MUST ATTENTION follow ALL steps regardless of perceived simplicity. "Too simple to plan" is an evasion, not a reason.
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.
MANDATORY Bootstrap task tracking before target work; transition one task at a time.
MANDATORY Persist plan/review findings to plans/reports/ incrementally and synthesize from disk.
MANDATORY After task-tracking bootstrap and before target/source work, read required project-reference docs and cite Reference docs read: ....
MANDATORY Always include lessons.md; project conventions override generic defaults.
MANDATORY If project config, root instruction files, or any required reference doc is missing or stale, auto-run $project-init or the narrow lower-level route before ordinary project-specific work.
MANDATORY Parent workflow rows do not replace child phase tracking; expand phases and link the parent when nested.
MANDATORY Orchestrators pre-expand child skill phases before invocation; use [N.M] $skill-name — phase prefixes and one-in_progress discipline.
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: Produce integration tests that exercise real production paths and assert specific DB field values — so every test protects a traceable business behavior (TC), survives repeated runs without reset, and fails only when the protected intent actually breaks.
Protocols in force (concise digest of the SYNC/shared blocks this skill carries) — MUST ATTENTION each canonical body below is in force; this digest is the signpost, NEVER the substitute:
Source/Test Drift Check: on source change, adjudicate whether tests or source is wrong.
AI Mistake Prevention: verify generated content against evidence, trace downstream references, verify all affected outputs, re-read after context loss, surface ambiguity.
Critical Thinking: every claim needs traced proof; never present a guess as fact.
Understand Code First: read existing code and grep 3+ patterns before writing.
Graph Impact Analysis: run blast-radius when graph.db exists; flag stale impacted files.
Repeatable Test Principle: unique data, additive-only, no reset — pass 3 consecutive runs.
Red Flag Stop Conditions: escalate on low confidence, large blast radius, breaking change.
Rationalization Prevention: reject step-skipping evasions; show grep evidence, plan anyway.
Incremental Persistence: persist findings to plans/reports/ after each file, never in memory.
Sub-Agent Return Contract: sub-agents return only the summary shape, detail on disk.
Sub-Agent Selection: route specialized domains to matching specialists, never code-reviewer.
Nested Task Creation: child skills expand visible phase tasks and link the parent.
Task Tracking & External Report: bootstrap task breakdown, transition one task at a time.
MANDATORY IMPORTANT MUST ATTENTION NEVER write smoke-only tests — instead read handler/entity/event source, assert specific changed field values — why: DI-resolution / exception-null-only tests pass while the behavior is broken
MANDATORY IMPORTANT MUST ATTENTION ALWAYS use async polling for EVERY DB assertion — no exceptions, not just async handlers — why: event handlers, message-bus consumers, background jobs, write latency delay persistence
MANDATORY IMPORTANT MUST ATTENTION NEVER fabricate state by direct repository writes — instead drive state through real command/query/seeder paths or valid seeded fixtures — why: shortcut data creates invalid state the suite then certifies
MANDATORY IMPORTANT MUST ATTENTION search 3+ existing tests in the SAME service and READ references/integration-test-patterns.md BEFORE writing — match collection, base class, helpers, unique-name generators — why: local conventions override generic templates
MANDATORY IMPORTANT MUST ATTENTION cite file:line evidence (confidence >80% to act, <60% do NOT recommend) for every claim about field changes, entities, or handler behavior — why: AI hallucinates APIs/signatures; grep to confirm before asserting
MANDATORY IMPORTANT MUST ATTENTION task tracking — break ALL work into small tasks BEFORE starting; transition one task at a time, add a final review task — why: tracking survives context loss/compaction
MANDATORY IMPORTANT MUST ATTENTION every test method carries a TC-{FEATURE}-{NNN} test-spec annotation — auto-create in Section 8 ONLY for genuinely uncovered business behavior — why: the annotation is the join key for traceability
MANDATORY IMPORTANT MUST ATTENTION one business TC maps to MANY tests (1:N, integration + unit) — NEVER split or technicalize a TC to force 1:1 — why: 1:1 splitting breaks the spec's business/user-story orientation (M1/M5)
MANDATORY IMPORTANT MUST ATTENTION for any handler enforcing a [HARD] §4 rule or §5 invariant, generate a Pattern 9 property/metamorphic test + boundary counter-case tied to a §8 Invariant/Property TC — why: example tests guard fixed points; the rule must fail across its whole input domain (mutation-kill, not line-coverage)
MANDATORY IMPORTANT MUST ATTENTION NEVER create Queries/ or Commands/ folders — instead organize by domain feature — why: CQRS-type folders fragment a domain across directories
MANDATORY IMPORTANT MUST ATTENTION NEVER mark done after one green run — verification requires 3 consecutive $integration-test-verify passes WITHOUT a DB reset — why: one run proves only the current run, not repeatability
MANDATORY IMPORTANT MUST ATTENTIONreview/verify are lightweight in-skill MODES — invoke the standalone $integration-test-review and $integration-test-verify skills for the heavier workflow gates — why: name-collision; modes are not the sibling skills
MANDATORY IMPORTANT MUST ATTENTION a direct user question — validate workflow/route decisions with the user. NEVER auto-decide complexity.
MANDATORY IMPORTANT MUST ATTENTION passing code/tests NEVER outrank canonical spec intent — instead reach adjudication-required with evidence before changing spec/test/code on a behavior mismatch — why: a green test can encode a regression
Anti-Rationalization:
Evasion
Rebuttal
"Test is simple, skip TC lookup"
TC traceability = test value. Skip = untraceable test.
"Async polling not needed here"
ALL DB assertions need polling. Handler type irrelevant.
"Already searched patterns"
Show file:line evidence. No proof = no search.
"Smoke test is fine for now"
Smoke-only FORBIDDEN. Assert specific field values.
"Repo setup is faster"
Direct repository data hacks create invalid state. Use real use-case paths or valid seeded fixtures.
"One green run is enough"
Verification requires 3 consecutive passing runs without DB reset.
"REVIEW: one pass is enough"
Low confidence → spawn fresh sub-agent. Never declare PASS after Round 1.
"Skip task creation, it's obvious"
task tracking is non-negotiable. Tracking prevents context loss.
"Split this TC so tests map 1:1"
One business TC → MANY tests is the expected shape. Splitting breaks spec business orientation (M1/M5).
"Example tests cover the rule"
A [HARD] §4 rule / §5 invariant needs a Pattern 9 property test — examples guard fixed points only.
"Run review mode, it's the gate"
review/verify modes are inline passes; the workflow gates are the standalone $integration-test-review + $integration-test-verify skills.
Closing reminder — Easy to Change is the success metric. Every finding,
test, refactor, and abstraction must answer one question: does this make
the next change cheaper or more expensive? If it doesn't reduce future
change cost, reject it. Coupling, hidden state, duplicated knowledge, and
unclear intent are the real enemies — call them out by name.
[WORKFLOW-EXECUTION-PROTOCOL] [BLOCKING] Workflow Execution Protocol — MANDATORY IMPORTANT MUST CRITICAL. Do not skip for any reason.
Generic portability boundary: Reusable skills and protocol text stay project-neutral; project-specific conventions are discovered from docs/project-config.json and docs/project-reference/. Apply shared AI-SDD from shared/sdd-artifact-contract.md. Read docs/project-config.json and docs/project-reference/docs-index-reference.md, then open the project reference docs named there. For spec, test-case, behavior-change, public-contract, or docs/specs/ work, route through the local spec docs named by the docs index: feature-spec-reference.md, spec-system-reference.md, spec-principles.md, and workflow-spec-test-code-cycle-reference.md when specs/tests/code must stay synchronized. If either file or a required reference doc is missing or stale, auto-run $project-init (or the narrow lower-level route such as $project-config, $docs-init, $scan-all, or $scan --target=<key>) before ordinary project-specific work. Any supported AI tool may execute when this shared context and local docs are available.
DETECT: If the prompt starts with an explicit slash skill/workflow command, execute it directly. Otherwise match the prompt against the workflow catalog and skill list.
ANALYZE: Choose the best option: execute directly, invoke a skill, activate a standard workflow, or compose a custom step combination.
AUTO-SELECT: Pick the best option yourself. Do not ask the user to choose between direct execution, skill, standard workflow, or custom workflow.
ACTIVATE: For a selected workflow, call $start-workflow <workflowId>; for a selected skill, invoke that skill; for a custom workflow, sequence custom steps directly; for direct execution, proceed with the task.
CREATE TASKS: task tracking for ALL workflow/skill/custom steps before execution when the selected path has multiple steps.
EXECUTE: Advance per the Workflow Step Advancement & Parallel Phases rule in your context instructions — model-driven; a sub-agent completion advances a step identically to an inline call; a parallel-phase group is an all-return barrier (advance only after ALL members return, never serialize it)
Trace every requirement or invariant through decision, task, TC/test, source evidence, and docs/spec update.
Treat code-to-spec extraction as reference-only until accepted by the canonical spec owner.
Any supported AI tool may plan, implement, review, or verify with synced context; using multiple tools is optional.
Update .claude source first, then sync generated mirrors; do not manually edit .agents, .codex, or AGENTS.md. — why: mirrors are generated artifacts; hand-edits are overwritten on the next sync
If docs/project-config.json, root instruction files, or a required project-reference doc is missing or stale, auto-run $project-init or the narrow lower-level route before ordinary project-specific work.
Active reference:shared/sdd-artifact-contract.md in the active skills root.
SYNC:ai-sdd-artifact-contract:reminder
MANDATORY Apply shared/sdd-artifact-contract.md; keep reusable AI-SDD in .claude and local rules in project docs.
MANDATORY Code-to-spec extraction is reference-only until canonical acceptance; any supported AI tool may execute with synced context.
MANDATORY Update .claude source before syncing generated mirrors; do not manually edit .agents, .codex, or AGENTS.md.
MANDATORY Missing or stale project config, root instruction files, or required reference docs route project-specific work through $project-init or the narrow setup route automatically.
[TASK-PLANNING] [MANDATORY] BEFORE executing any workflow or skill step, create/update task tracking for all planned steps, then keep it synchronized as each step starts/completes.
[LESSON-LEARNED-REMINDER] [BLOCKING] Task Planning & Continuous Improvement — MANDATORY. Do not skip.
Break work into small tasks (task tracking) before starting. Add final task: "Analyze AI mistakes & lessons learned".
Extract lessons — ROOT CAUSE ONLY, not symptom fixes:
Name the FAILURE MODE (reasoning/assumption failure), not symptom — "assumed API existed without reading source" not "used wrong enum value".
Generality test: does this failure mode apply to ≥3 contexts/codebases? If not, abstract one level up.
Write as a universal rule — strip project-specific names/paths/classes. Useful on any codebase.
Consolidate: multiple mistakes sharing one failure mode → ONE lesson.
Recurrence gate: "Would this recur in future session WITHOUT this reminder?" — No → skip $learn.
BOTH gates pass → ask user to run $learn.
[CRITICAL-THINKING-MINDSET] Apply critical thinking, sequential thinking. Every claim needs traced proof, confidence >80% to act.
Anti-hallucination principle: 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.
AI Attention principle (Primacy-Recency): Put the 3 most critical rules at both top and bottom of long prompts/protocols so instruction adherence survives long context windows.
Goal-driven execution: Define success criteria first, loop until verified, and stop only when observable checks pass.
Tests verify intent: Tests must protect business rules/invariants and fail when the protected intent breaks, not only mirror current behavior.
Common AI Mistake Prevention (System Lessons)
Re-read files after context compaction. Edit requires prior Read in same context; compaction wipes read state. Re-read before editing.
Grep for old terms after bulk replacements. AI over-trusts find/replace completeness. Grep full repo after bulk edits for missed refs in docs/configs/catalogs.
Check downstream references before deleting. Deletions cascade doc/code staleness. Map referencing files before removal.
After memory loss, check existing state before creating new. Compaction wipes prior-work memory. Query current state to resume — never blindly duplicate.
Verify AI-generated content against actual code. AI hallucinates APIs, class names, method signatures. Grep to confirm existence before documenting/referencing.
Trace full dependency chain after edits. Changing a definition misses downstream consumers. Trace the full chain.
When renaming, grep ALL consumer file types. Some file types silently ignore missing refs (no compile error). Search code, templates, configs, generated files.
Trace ALL code paths when verifying correctness. Code existing ≠ code executing. Trace early exits, error branches, conditional skips — not just happy path.
Update docs that embed canonical data when source changes. Docs inlining derived data (workflows, schemas, configs) go stale silently. Update all embedding docs alongside source.
Verify sub-agent results after context recovery. Background agents may finish while parent compacted — grep-verify output, don't trust assumed completion.
Cross-check full target list against sub-agent assignments. Parallel sub-agents by category miss boundary items. Reconcile union of assignments against target list before proceeding.
Sub-agents inherit knowledge only from their agent .md definition — use custom agent types, not built-in Explore. Tool adoption = permission + knowledge + enforcement (numbered workflow step).
Persist sub-agent findings incrementally, not as a final batch. Long sub-agents hit cutoffs before final write — findings lost. Instruct append-per-section to report file.
When debugging, ask "whose responsibility?" before fixing. Trace caller (wrong data) vs callee (wrong handling). Fix at responsible layer — never patch symptom site.
Grep ALL removed names after extraction/refactoring. Primary file "done" ≠ secondary files clean. Grep entire scope for every removed symbol before declaring complete.
Assume existing values are intentional — ask WHY before changing. Pattern-matching as "wrong" skips context. Before changing any constant/limit/flag: read comments, git blame, surrounding code.
Verify ALL affected outputs, not just the first. One build green ≠ all green. Multi-stack changes (backend/frontend/tests/docs) require verifying EVERY output.
Evaluate fit before copying a nearby pattern. Closest example ≠ matching preconditions — verify the new context shares the same constraints, base classes, scope, lifetime.
Este SKILL.md e muito grande, entao o SkillsMP mostra aqui apenas a primeira secao.Ver no GitHub