agentleFS
moberghrmoberghr/mtk-agent-toolkit/.claude/skills/prior-work-check/SKILL.md

prior-work-check

Skill8 starsChanged 3 days agoMITView on GitHub

Use before approving a spec or starting a multi-file implementation to confirm no existing skill, helper, or handler already covers the proposed work.

The file

We split this skill into the rules it gives an agent

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

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈3

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 4

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    When the engineer says "let's add an X" and X sounds generic (cache, retry, validator, formatter, normalizer)

    line 25
  2. Distinctive:

    Look for an existing implementation of the capability under any name.

    line 36
  3. Very specific:

    If CODE_INDEX.md exists at the repo root, query it with bash scripts/query-code-index.sh find "<keyword>" (case-insensitive row search that …

    line 44
  4. Very specific:

    If an MCP code-index tool is available (e.g.

    line 50
  5. Very specific:

    Run the query above (search_prior_work) as usual to catch capability duplication.

    line 65
  6. Very specific:

    No match after synonyms → PASS.

    line 95
  7. Distinctive:

    Read-only: it reports, the caller decides.

    line 100

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

Prior Work Check

Tool discipline: read-only — Read/Grep/Glob and read-only Bash queries. Never Edit/Write; report what exists and let the caller decide.

Overview

Before writing new code, confirm the codebase doesn't already do this — re-implementing a capability that exists under a different name is the most common waste in mature codebases. Runs once per implement run: spec-driven step 9 for a fresh request, or Phase 0.7's reconciliation mode when the engineer supplied the plan. Lessons and security-impact classification are covered elsewhere (the lessons query in Phase 0, the spec's security-impact step and drift check) and are not repeated here.

When To Use

  • spec-driven-development step 9, before the implement Phase 2.5 approval gate
  • implement Phase 0.7 when a pre-written plan is supplied as input — the reconciliation mode below, so already-implemented batches are not re-run
  • When the engineer says "let's add an X" and X sounds generic (cache, retry, validator, formatter, normalizer)

When NOT To Use

  • Typo fixes, single-line config tweaks, or bug fixes where the file in scope is already named
  • A second time in the same run — planning does not re-run it

Workflow

Query — search_prior_work

Look for an existing implementation of the capability under any name.

  1. Extract 2-4 capability keywords from the spec summary and success_criteria. Verbs + nouns ("issue token", "retry policy", "currency formatter").
  2. Run, in parallel:
    • grep -rn -i "<keyword>" --include="*.cs" --include="*.py" --include="*.ts" --include="*.tsx" --include="*.js" src/ (or the active stack's source roots — read .claude/tech-stack).
    • If CODE_INDEX.md exists at the repo root, query it with bash scripts/query-code-index.sh find "<keyword>" (case-insensitive row search that prints each match prefixed with its ## <Domain> section) rather than a raw grep. If the script is absent (repo bootstrapped before v7.17) or the keyword may live outside table rows (domain headings, prose), fall back to grep -i "<keyword>" CODE_INDEX.md.
    • If an MCP code-index tool is available (e.g. mcp__ast-index__*), prefer it over raw grep.
  3. For each hit, report:
    • file:line
    • one-line summary of what it does
    • whether it can be reused, extended, or is genuinely different

Existing-Plan Reconciliation Mode

Invoked by implement Phase 0.7 when the input is a pre-written plan (supplied by the engineer) rather than a fresh request. A supplied plan may be stale — some batches were implemented since it was written. Re-implementing done work is waste and a drift risk, so reconcile the plan against current code before the Phase 2.5 gate:

  1. Run the query above (search_prior_work) as usual to catch capability duplication.
  2. Per-batch satisfied-check (read-only). For each batch in the supplied plan, take its acceptance / verification / linked success_criteria and probe current code for whether it is already satisfied:
    • grep for the batch's target symbols and change_manifest paths (and any public-contract signatures) and read the relevant lines;
    • where a batch has a runnable, non-mutating verification, note whether it already passes. Never mutate state to find out.
    • Classify each batch: already-satisfied | partially-done | not-started, each with file:line evidence.
  3. Emit a reconciliation table (batch id → classification → evidence). The orchestrator then, before Phase 2.5: marks already-satisfied batches complete/skipped in the JSON sidecar and ticks them in tasks/todo.md with a one-line note naming what was pruned; surfaces partially-done batches for the engineer to re-scope. Never silently re-run a done batch, and never edit source here — this mode only classifies and reports.

Output

### Prior Work Check
- match: src/Auth/TokenService.cs:42 — already issues JWTs. **Reuse, do not
  reimplement.** Spec should be revised to extend, not create.
- (no other matches; synonyms tried: "token", "jwt", "bearer")

Verdict

  • An existing implementation the spec would duplicate → BLOCKED; revise the spec to reuse or extend it before the gate.
  • A near match that could be extended → PROCEED_WITH_CHANGES; the engineer decides, and a deviation is justified in writing.
  • No match after synonyms → PASS.

Rules

  • A grep miss is not a confirmed absence. If the capability is generic, widen the search with synonyms before declaring PASS.
  • Read-only: it reports, the caller decides.

Verification

  • The query ran with output captured, and at least one synonym was tried
  • In reconciliation mode, every supplied batch is classified with file:line evidence
  • Verdict matches the strongest match found

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.