agentleFS
sd0xdevsd0xdev/sd0x-harness/skills/test-deep/SKILL.md

test-deep

Skill191 starsChanged 2 months agoMITView on GitHub

Context-aware test orchestration. Use when: smart test selection, failure triage, progressive test ladder, test failure analysis. Not for: writing tests (use post-dev-test), reviewing tests (use codex-test-review), generating tests (use codex-test-gen), full manual run (use verify). Output: test results + triage report + fixer actions.

  • Deletes or force-pushes
  • Commits and pushes

The file

We split this skill into the rules it gives an agent

7 rules. About 0 are common, 4 are distinctive, and 3 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈4

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 3

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    When test failures occur, dispatch background triage:

    line 11
  2. Very specific:

    Execution: Run tests using project's configured test command (from package.json scripts or CLAUDE.md).

    line 108
  3. Very specific:

    When failures occur, analyze and classify.

    line 112
  4. Very specific:

    Mandatory secret redaction: before LLM analysis — per @rules/logging.md:

    line 138
  5. Distinctive:

    Fixer loop: After safe/approved fixer runs, re-enter progressive ladder for failed tests only.

    line 170
  6. Distinctive:

    Write per-run artifacts for comparison and debugging.

    line 174
  7. Distinctive:

    TTL: Keep last 5 runs. Prune older on new run start.

    line 187

≈ “Common” is an estimate: at least 1 in 5 of the 213,895 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

Test Deep — Context-Aware Test Orchestration

Supplementary Agent

When test failures occur, dispatch background triage:

Agent({ description: "Analyze test failure root cause and suggest fixes", subagent_type: "verify-app", prompt: Analyze the following test failure: <failure output> Identify root cause and suggest minimal fix. })

Trigger

  • Keywords: context-aware testing, smart test, test orchestration, test triage, test failure analysis, test deep, run relevant tests

When NOT to Use

ScenarioAlternative
Writing new tests/post-dev-test
Reviewing test coverage/codex-test-review
Generating unit tests/codex-test-gen
Full manual test run/verify
Code review/codex-review-fast

Prohibited Actions

❌ git add | git commit | git push — per @rules/git-workflow.md

This skill runs tests and may apply safe fixers, but does not commit. To commit, offer the menu per rules/git-workflow.md § Proactive Offer — a commit option on any real branch, a push option only where review-state.js offer allows one — and invoke /smart-commit --execute on selection; never print the command for the user to copy.

Workflow

flowchart TD
    U[User: /test-deep] --> S[Phase 0: Test Selection]
    S --> |git diff mapping| T[Test Targets]
    S --> |no mapping| F1[Framework --changedSince]
    S --> |low confidence| F2[Full Suite]
    T --> L[Phase 1: Progressive Ladder]
    F1 --> L
    F2 --> L
    L --> |unit| R1[Run Unit Tests]
    R1 --> |pass| R2[Run Integration Tests]
    R1 --> |fail| TR[Phase 2: Triage Pipeline]
    R2 --> |pass| R3[Run E2E Tests]
    R2 --> |fail| TR
    R3 --> |pass| DONE[All Pass]
    R3 --> |fail| TR
    TR --> P[Parser: Structured Tags]
    P --> LLM[LLM: Root Cause + Action]
    LLM --> FC[Phase 3: Fixer Catalog Lookup]
    FC --> SG{Safety Gate}
    SG --> |safe| AUTO[Auto-run Fix]
    SG --> |side-effect| ASK[AskUserQuestion]
    SG --> |destructive| BLOCK[Manual Only]
    AUTO --> L
    ASK --> |approved| L

Phase 0: Test Selection

Map code changes to test targets. See references/test-selection.md for full strategy.

Strategy priority:

PriorityMethodWhen
1Git diff filename mappingDefault — map changed files to test files via Glob
2Framework nativeJest --changedSince, Vitest --changed
3Full suite fallbackConfig change, no mapping, --all flag

Steps:

  1. Collect changed files: union of unstaged + staged + untracked (--branch uses merge-base)
  2. Apply filename mapping rules to generate candidate test paths
  3. Glob-confirm each candidate exists
  4. Classify confirmed tests by layer (unit / integration / e2e)

Full suite escalation triggers: config file changed, CI/CD file changed, package dependency changed, no test files mapped, --all flag.

Phase 1: Progressive Ladder

Execute tests layer-by-layer with fail-fast.

LayerDirectory PatternTimeoutFail Behavior
Unittest/unit/**, test/scripts/lib/**, unclassified60sFail-fast → triage
Integrationtest/integration/**300sFail-fast → triage
E2Etest/e2e/**600sEnter triage

Fail-fast rule: Unit fail → skip integration + e2e. Integration fail → skip e2e.

Override: --no-fail-fast disables this behavior (run all layers regardless).

Layer detection: Classify test files by directory prefix. Files not matching any integration/e2e pattern → treat as unit.

Execution: Run tests using project's configured test command (from package.json scripts or CLAUDE.md). Capture stdout/stderr and exit code.

Phase 2: Failure Triage Pipeline

When failures occur, analyze and classify. See references/triage-pipeline.md for full spec.

Step 1: Output Parser

Extract structured tags from test output (no classification — just structure):

TagDescription
exit_codeProcess exit code
error_signatures[]Regex-matched error patterns
failing_tests[]Failed test names
failing_files[]Failed test file paths
env_hints[]Environment clues (testnet, localhost, etc.)
stack_depthStack trace line count

Step 2: LLM Root Cause Analysis

Feed parser tags + compressed output to LLM for classification:

ClassificationDefinitionTypical Action
code_bugLogic error in codeFix code
infraInfrastructure issue (port, dependency)Restart / reinstall
environmentExternal precondition unmetFixer catalog action
flakyNon-deterministic failureRetry + quarantine tag

Mandatory secret redaction before LLM analysis — per @rules/logging.md:

  • API keys, private keys, tokens, passwords, mnemonics, URLs with credentials
  • See references/triage-pipeline.md for redaction patterns

Step 3: Safety-Gated Action

Route suggested_fixer through safety gate:

TierAuto-run?ConfirmationExamples
safeYesNoneretry, clear_cache
side-effectNoAskUserQuestionreinstall_deps, restart_server
destructiveBlockedManual onlyReset state, drop tables

Default-deny: Unknown fixer → side-effect tier (require confirmation).

Phase 3: Fixer Execution

Lookup fixer from catalog, check tier, execute or prompt. See references/fixer-catalog.md for full catalog.

Core fixers (plugin-shipped):

FixerTierDescription
retrysafeRe-run failing tests
clear_cachesafeClear build/test cache
reinstall_depsside-effectRemove node_modules + reinstall
restart_serverside-effectKill + restart dev server
port_cleanupside-effectKill process on conflicting port

Host extensions: Project-specific fixers in .claude/test-deep/fixers.md. Schema validation at load — missing required fields or invalid tier → rejected with warning.

Fixer loop: After safe/approved fixer runs, re-enter progressive ladder for failed tests only. Max 1 fixer retry per failure to prevent infinite loops.

Session Artifacts

Write per-run artifacts for comparison and debugging.

Location: .claude/cache/test-deep/<runId>/

Run ID format: <timestamp>-<shortSHA>-<pid>

FileContent
metadata.jsonRun config: selected tests, ladder config, changed files
results.jsonPer-layer results: pass/fail, duration, exit codes
triage.jsonParser tags, LLM classification, fixer chosen, outcome
output.logCompressed test output (secret-redacted)

TTL: Keep last 5 runs. Prune older on new run start.

latest symlink: Points to most recent run directory.

Arguments

FlagDefaultDescription
--allfalseForce full test suite
--layer <unit|integration|e2e>allRun only specified layer
--no-fail-fastfalseRun all layers regardless of failures
--no-fixfalseTriage only, skip fixer execution
--focus <path>—Limit test selection to path
--branchfalseUse merge-base diff instead of working tree

Output

## Test Deep Report

### Test Selection
- Changed files: N
- Mapped test files: N (N unit, N integration, N e2e)
- Selection method: git diff mapping | framework native | full suite

### Results

| Layer | Tests | Passed | Failed | Skipped | Duration |
|-------|-------|--------|--------|---------|----------|

### Failure Triage

| # | Test | Classification | Root Cause | Fixer | Tier |
|---|------|---------------|------------|-------|------|

### Actions Taken
- [N] fixer_id: outcome

### Gate
✅ All Pass | ⛔ N failures pending resolution

Verification Checklist

  • Test selection maps changed files to test targets
  • Progressive ladder respects fail-fast
  • Triage pipeline produces structured classification
  • Safety gate enforces tier-based execution
  • Secret redaction applied before LLM analysis
  • Session artifacts written to cache
  • No git add / git commit / git push executed

References

  • references/test-selection.md — Git diff mapping strategy + full suite escalation
  • references/triage-pipeline.md — Parser tags + LLM prompt + safety gate
  • references/fixer-catalog.md — Core fixers + host extensions + safety tiers
  • @rules/logging.md — Secret redaction policy
  • @rules/docs-writing.md — Output format conventions

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.