AGENT SKILL

write-tests

Use whenever adding, changing, reviewing, or debugging tests in the ai-conductor repository. Defines repository-specific test scope, isolation, mocking, fixture, performance, and CI-parity rules that prevent cyclic Conductor runs, leaked workers, real third-party calls, and slow aggregate suites. Complements the provider-neutral tdd skill, which controls implementation order rather than test design.

License 许可
Apache-2.0
最近更新
2026-11-14
Stars
★ 7
Forks
2

01 前言 Front Matter

name
write-tests
description
Use whenever adding, changing, reviewing, or debugging tests in the ai-conductor repository. Defines repository-specific test scope, isolation, mocking, fixture, performance, and CI-parity rules that prevent cyclic Conductor runs, leaked workers, real third-party calls, and slow aggregate suites. Complements the provider-neutral tdd skill, which controls implementation order rather than test design.
disable-model-invocation
true

02 资源文件 1

03 SKILL.md 正文

Write Tests

Design tests for this repository. Use the provider-neutral tdd skill separately when implementing behavior test-first.

1. Classify the test

Choose the narrowest level that proves the behavior.

  • Unit: Exercise one function, class, transition, or adapter contract. Inject dependencies and mock every process, network, LLM, GitHub, filesystem boundary not under test.
  • Integration: Exercise real collaboration between selected internal components. Use real temporary files or local Git only when they are the boundary under test. Fake all third-party services.
  • Acceptance: Exercise an observable story or gate across the minimum real internal path. Fake third-party boundaries; create only the authoritative artifacts the scenario requires.
  • Smoke: Exercise a real executable or third-party service. Put it under src/conductor/test/smoke/ or name it *.smoke.test.ts. Smoke tests are excluded from the ordinary suite.

Only explicit smoke tests may call real Claude, Codex, GitHub, package registries, HTTP services, or other third parties.

2. Select the seam before writing the fixture

Name the exact behavior and terminal observation first. Test that seam directly.

  • Prefer exported pure helpers for selection, classification, ordering, and state calculations.
  • For an engine-native boundary, invoke the smallest method that owns the behavior.
  • Use Conductor.run() only when the test must prove orchestration across multiple steps.
  • Never use a full conductor run merely to prove plugin registration, provider invocation, marker contents, configuration resolution, event emission, or one state transition.

If the assertion can be made without completing the full workflow, the test MUST stop at that boundary.

3. Bound every Conductor fixture

Before calling Conductor.run(), write down:

  1. The first step that may run.
  2. The exact steps expected to dispatch.
  3. The condition that ends the run.
  4. Every completion artifact or gate verdict required before that endpoint.

Then enforce these rules:

  • Pre-resolve unrelated steps in conduct-state.json.
  • Use fromStep for a targeted transition.
  • Use resume only when resume selection itself is under test; otherwise test findResumeIndex directly.
  • Keep verifyArtifacts: false for mocked-success unit flows. Mocked runner success is their authority.
  • With verifyArtifacts: true, create fresh, valid evidence for every participating gate. Status done alone is not evidence.
  • In auto mode, account for the whole validation group: manual_test, prd_audit, and architecture_review_as_built. Either supply valid evidence for every applicable member or configure a real skip condition.
  • At the finish boundary, ensure validator evidence is current for the session and HEAD. Never reuse a stale marker accidentally.
  • For a dispatch-time observation, terminate immediately after the observation with an injected, expected sentinel failure and await the conductor's cleanup. Do not let the run continue into unrelated gates.

Never rely on Vitest's timeout to stop a conductor. A timed-out test does not cancel its async work; the orphan can keep rewriting temporary state and contaminate hundreds of later tests.

4. Mock external boundaries through dependency injection

Mock the adapter, not internal domain behavior.

  • Inject StepRunner, LLMProvider, Git/GitHub runners, clocks, sleeps, process launchers, and verifier interfaces.
  • Assert calls and returned domain results at the injected boundary.
  • Do not spawn claude, codex, gh, curl, wget, npm install, npm ci, or bin/setup in ordinary tests.
  • Do not hide a real external call behind a variable, wrapper, shell string, or dynamically assembled argv.
  • Acceptance and integration tests should use the real internal implementation up to the third-party adapter, then use a deterministic fake.

Use real local Git repositories only for behavior that depends on Git semantics. Pin the initial branch, configure local identity, avoid remotes unless the remote itself is the subject, and clean up the exact mkdtemp directory.

5. Keep time deterministic

  • Inject clocks and sleep functions.
  • Use fake timers only when the timer behavior is the subject.
  • Never add real waits to make a race pass.
  • Never raise a timeout to accommodate a unit or ordinary integration test.
  • Prefer unit tests under 100 ms and ordinary test files under 2 seconds.
  • A real-local-Git integration may take longer, but must remain bounded and should usually finish under 10 seconds.

A 20-second timeout is a defect signal, not a performance budget.

6. Keep cleanup trustworthy

  • Create isolated state with mkdtemp.
  • Await every started promise before afterEach removes its directory.
  • Stop watchers, timers, subprocesses, event listeners, and abort controllers in finally paths.
  • Never let cleanup race a still-running conductor.
  • Treat ENOTEMPTY after a timeout as evidence of unfinished async work. Find the live loop or worker; do not add retrying cleanup.

7. Avoid false integration tests

Remove or rewrite a test when it:

  • retrieves a provider but never injects it into the system under test;
  • runs the whole conductor with an all-success runner only to assert one call;
  • asserts feature_status: complete without creating the gate evidence required by the current architecture;
  • duplicates a pure registry, policy, or helper assertion through a full workflow;
  • invokes the repository's aggregate test command from inside Vitest;
  • passes alone but fails in a group because it leaks module mocks, process state, listeners, workers, or files.

An integration label does not justify a broad path. Preserve the real boundary and delete the ceremony.

8. Verify with CI parity

During authoring, run the project's narrowest test invocation for the file under work.

The required CI typecheck job (npm run typecheck:test) and lint job in .github/workflows/ci.yml are the gate that proves test files type-check and lint.

A test whose verdict depends on the live repository .docs/ corpus belongs in src/conductor/test/corpus/, because docs-only pull requests run only that tier. A projection-limit check in that tier asserts that the shipped limits admit the corpus, never equality with a recorded snapshot.

The engine-native test_suite gate owns aggregate test execution as HARNESS.md defines; authoring and diagnosis never launch it.

The ordinary suite must finish in under five minutes. The expected healthy range is roughly two to three minutes. If it exceeds five minutes, inspect active workers and recent temporary fixture state; do not wait indefinitely.

9. Diagnose a slow or wedged suite

  1. Stop only the exact local test-runner workers started by the current diagnostic run.
  2. Re-run the last reported file or test name in isolation with a concise reporter.
  3. If it times out, inspect its live temporary conduct-state.json and .pipeline/phase-active before cleanup.
  4. Look for repeated stale validator states, unchanged gate evidence, or a mocked-success runner traversing an artifact-driven finish fence.
  5. Fix the inconsistent authority or fixture boundary.
  6. Run the formerly failing files together; isolation-only success is insufficient.

What is already mechanized — point at it, do not restate it

  • AI_CONDUCTOR_NO_REAL_EXEC in src/conductor/test/setup.ts is a partial backstop for the §4 external-boundary rules: it covers only daemon launch, the pr-labels gh/git seam, and the engineer directory.
  • The suite leak guards tmpdir-leak-guard.ts, pipeline-leak-guard.ts, signals-leak-guard.ts, park-leak-guard.ts, and tmux-leak-guard.ts under src/conductor/test/ are a partial backstop for the §6 cleanup rules: they detect leaks after the run.
  • The default vitest.config.ts exclusion of test/smoke/**, *.smoke.test.ts, and *.e2e.test.ts is a partial backstop for §1 smoke and e2e placement: it excludes by name but cannot classify a test.
  • The CI typecheck:test and lint jobs in .github/workflows/ci.yml back §8.

Each backstop is partial, so the rule it backs remains binding.

Completion checklist

  • The test proves one named behavior at the narrowest credible level.
  • No ordinary test can reach a real LLM or third-party service.
  • Every async operation has an awaited terminal path.
  • Conductor fixtures declare and satisfy only their required gates.
  • The test passes both alone and with affected neighboring files.
  • Each test whose verdict depends on the live .docs/ corpus is in src/conductor/test/corpus/, and projection-limit checks there assert admission rather than equality with recorded maxima.

04 同仓库更多 Skills

jstoup111
jstoup111/ai-conductor

build-review-dependency-hygiene

Judge whether a feature diff adds unnecessary, insufficiently pinned, or license-incompatible dependencies.

★ 7
jstoup111
jstoup111/ai-conductor

writing-system-tests

Use BEFORE implementing any feature that has stories in .docs/stories/ — generates failing acceptance specs from acceptance criteria as the RED phase of TDD. Generates HTTP/request-level acceptance tests for headless/API projects, end-to-end UI tests for projects with a frontend, using the project's own test framework and directory conventions.

★ 7
jstoup111
jstoup111/ai-conductor

verify-claims

Use only when an active workflow is about to rely on a nontrivial factual claim or assumption for a spec, plan, ADR, finding, or code decision. Do not invoke for casual questions, status reports, restatements, or trivially verifiable mechanics.

★ 7
jstoup111
jstoup111/ai-conductor

tdd

Use when implementing any feature or bugfix. Five-step cycle: RED → DOMAIN → GREEN → DOMAIN → COMMIT. Enforces test-first development with domain integrity review at every phase boundary.

★ 7
jstoup111
jstoup111/ai-conductor

stories

Use only within active engineer/conduct DECIDE after architecture approval, when a committed `.docs/stories` acceptance artifact is required. Do not invoke for general user-story examples, requirements discussion, or direct implementation requests.

★ 7
jstoup111
jstoup111/ai-conductor

stack-land

Use when an operator needs to land reviewed manual changes on the correct closed child of a stacked feature. Operator-invoked only: inspect ownership, propose the safe child with evidence, and require confirmation before opening the landing.

★ 7