agentleFS
anyoneandersonanyoneanderson/agent-skills/skills/spec-test/SKILL.md

spec-test

Skill3 starsChanged 8 days agoMITView on GitHub

Create and run tests for a spec task implementation.

2 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

10 rules. About 0 are common, 9 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈9

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Create tests based on task completion criteria, run them, and output structured results.

    line 17
  2. Very specific:

    Find test files: look for *.test.*, *.spec.*, __tests__/, test/, tests/ directories

    line 58
  3. Distinctive:

    If no existing tests found, use framework defaults appropriate to the language.

    line 63
  4. Distinctive:

    Write test files following detected patterns:

    line 75
  5. Distinctive:

    Place in the conventional test location

    line 76
  6. Distinctive:

    Import test helpers/fixtures if they exist

    line 77
  7. Distinctive:

    Follow naming conventions of existing tests

    line 78
  8. Distinctive:

    If a specific test file can be targeted, run only the new tests first, then the full suite.

    line 89
  9. Distinctive:

    All tests pass → PASS

    line 124
  10. Distinctive:

    Commit test files following project conventions:

    line 129

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

spec-test — Create and Run Tests for a Spec Task

Create tests based on task completion criteria, run them, and output structured results.

Language Rules

  1. Auto-detect input language → output in the same language
  2. Japanese input → Japanese output, use references/test-guide.ja.md
  3. English input → English output, use references/test-guide.md
  4. Explicit override takes priority

Options

OptionDescription
--task {task-id}Task ID to test (reads completion criteria from tasks.md)
--spec {path}Path to .specs/ directory
--files {paths}Target files to test (auto-detect from task if omitted)
--output {path}Output path for test result (default: .specs/{feature}/test-{task-id}.md)

Execution Flow

Step 0: Context Loading (Phase A / Phase B)

Same as spec-code §Step 0, but identify your role as tester.

Phase B applies when re-testing after a fix: focus on the specific test failures and changed code.

Step 1: Extract Test Requirements

From tasks.md, find the task matching --task {task-id} and extract:

  • Completion criteria (checkboxes)
  • Target files (implementation files to test)
  • Requirements ID (for traceability)

From design.md (if available):

  • Expected interfaces and behaviors
  • Edge cases mentioned in design

Step 2: Detect Test Patterns

Scan the project for existing test conventions:

  1. Find test files: look for *.test.*, *.spec.*, __tests__/, test/, tests/ directories
  2. Detect framework: Jest, Vitest, Mocha, pytest, Go test, Rust test, etc.
  3. Detect patterns: AAA (Arrange-Act-Assert), describe/it blocks, test helpers, fixtures
  4. Detect test commands: from package.json scripts, Makefile, CLAUDE.md, etc.

If no existing tests found, use framework defaults appropriate to the language.

Step 3: Design Test Cases

Based on completion criteria and design:

  1. Happy path tests: Each completion criterion → at least one test
  2. Edge cases: Empty inputs, boundary values, error conditions
  3. Negative tests: Invalid inputs, unauthorized access, missing data

Step 4: Create Tests

Write test files following detected patterns:

  • Place in the conventional test location
  • Import test helpers/fixtures if they exist
  • Follow naming conventions of existing tests
  • Apply AAA pattern (Arrange-Act-Assert)

Step 5: Run Tests

Execute the detected test command:

# Auto-detect and run
npm test / npx jest / npx vitest / pytest / go test / cargo test

If a specific test file can be targeted, run only the new tests first, then the full suite.

Step 6: Collect Results and Write Output

Output to --output path (default: .specs/{feature}/test-{task-id}.md):

# Test: {task-id}
type: test

## Meta
- Tester: spec-test
- Date: {ISO 8601}
- Command: {test command used}
- Framework: {detected framework}

## Results
- Tests: {passed}/{total} passed
- Coverage: {percentage}% (if available)
- Duration: {time}

## Test Cases
- [x] {test name} — {what it verifies}
- [x] {test name} — {what it verifies}
- [ ] {test name} — FAILED: {error message}

## Completion Criteria Coverage
| Criterion | Test | Status |
|---|---|---|
| {criterion from tasks.md} | {test name} | PASS / FAIL |

## Gate: PASS / FAIL

Gate logic:

  • All tests pass → PASS
  • Any test fails → FAIL

Step 7: Commit Tests

Commit test files following project conventions:

  • Default format: test(scope): {task-id} — {brief description}
  • Stage only test files

Error Handling

SituationResponse
--task ID not found in tasks.mdError: task ID not found
No test framework detectedWarning: suggest installing one, create basic tests
Test command fails to runError: report command and error output
Some tests failWrite results with FAIL gate, do not fix (spec-code handles fixes)
Coverage tool not availableWarning: skip coverage, note in results

Usage Examples

# Test a specific task
/spec-test --task T-007 --spec .specs/did-deactivation/

# Test with explicit file targets
/spec-test --task T-003 --spec .specs/auth-feature/ --files src/auth/service.ts

# Standalone (no spec context)
/spec-test --task T-001 --files src/utils/parser.ts

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.