/shipwright:duplication-fix runs instead · from shipwright
Queues task-store tasks for ready-to-propose duplication patterns, each with a strangler-fig execution plan. Requires a prior duplication-scan run.
This skill never runs in Claude Code
It ships in shipwright at skills/, but /shipwright:duplication-fix (a command, or a skill Claude Code finds first) has the same name: typing it, or Claude choosing it, runs that one instead.
Read one repo's ready_to_propose patterns from the task store's PatrolFinding
ledger (written by duplication-scan) and queue focused, human-reviewable tasks for
them. Each task proposes a canonical shape for one stabilized duplication pattern plus
a strangler-fig execution plan broken into small, separate PR-sized steps — never a
single sweeping diff. Findings are never turned into direct PRs; they always become
task-store tasks. Each is routed one of three ways (auto, review or plan — Step 7),
following the routing contract in docs/task-store.md ("Finding routing").
This is the duplication-scan counterpart that mirrors entropy-fix's
relationship to entropy-scan — same dedup mechanism, same task-store fields, same
queue-only contract. The two patrols (entropy and duplication) remain fully
decoupled: this skill never promotes a duplication finding into an entropy-scan
rule, and it never asks entropy-fix to do anything. That graduation/promotion
mechanism is explicitly out of scope.
Prerequisites: Run /duplication-scan --repo org/repo first so the repo has
ready_to_propose findings in the store.
Task store setup: This skill pushes findings to the Shipwright task store. If
SHIPWRIGHT_TASK_STORE_URLorSHIPWRIGHT_TASK_STORE_TOKENis missing, invoke/shipwright:task-storefor setup instructions.
--repo org/repo is required. If it is missing or not in org/repo form, print
this usage error and stop without reading or writing anything:
--repo is required.
Usage: /shipwright:duplication-fix --repo org/repo [--dry-run] [--pattern fingerprint]
Derive repo-slug from it: the last path segment, lowercased — e.g.
app-vitals/shipwright → shipwright. It is used in task ids (Step 8).
Flags:
--dry-run — print what tasks would be queued without querying the task store for
dedup or writing any tasks (the run is not recorded either)--pattern {fingerprint} — queue only the candidate whose fingerprint matches
(full or unambiguous prefix)Note: Queueing is the only mode. There is no PR mode and no
--queueflag — every run queues tasks.--dry-runshows a preview and stops without touching the task store.
PatrolFinding ledger. Follow
nextCursor until it is null — never proceed with a partial page:
curl -sf -H "Authorization: Bearer $SHIPWRIGHT_TASK_STORE_TOKEN" \
"$SHIPWRIGHT_TASK_STORE_URL/patrol-findings?cronId=duplication-patrol&repo={url-encoded-repo}&status=ready_to_propose&limit=200" | jq .
No ready_to_propose duplication patterns for {repo}. Nothing to queue.
Run /duplication-scan --repo {repo} again in future weeks to let more candidates stabilize.
Record the run (Step 10) with outcome: no_op and stop.ready_to_propose Entries Onlystatus: ready_to_propose — duplication-scan only sets that status once the
promotion gate is met, and tracking findings are never fetched. Do not
re-derive or re-check occurrence_count/consecutive_stable_runs thresholds here.--pattern was passed, filter to only the finding whose fingerprint
matches. If none matches, print: "No ready_to_propose entry with fingerprint
{pattern}. Nothing to queue." and stop. If the prefix matches more than one
finding — fingerprints are truncated hashes, so prefix collisions are possible —
print all matching fingerprints and stop, asking the caller to disambiguate:
Ambiguous --pattern `{pattern}` matches {N} entries:
{fingerprint-1} — {pattern description}
{fingerprint-2} — {pattern description}
...
Re-run with a longer prefix to disambiguate.
detail and the row: fingerprint,
description, files (occurrence list, file:line — note), proposed_shape,
firstSeen/lastSeen, and history.Even though duplication-scan already checks the decisions registry before
promoting a candidate to ready_to_propose (its Step 7), the registry can change
between when the finding was promoted and when this skill runs — a human may have
reviewed a prior duplication-fix PR and added a new accepted-debt entry since.
Never trust the stored promotion decision as still current; re-check live.
See references/decisions-registry.md for the shared decisions-registry pattern this
mirrors.
docs/duplication-decisions.md in the project root. This is the only
registry path: never read or write a decisions file under .claude/shipwright/.duplication-scan uses. Print: "No duplication-decisions.md
found — no suppressions configured." and continue to Step 4 with an empty
suppression list. This is expected and not an error.duplication-scan's Step 1 does: read each ### entry for its Pattern,
Decision, Rationale, and Revisit fields where present, but do not
hardcode assumptions about the registry's exact heading/field layout beyond
those four fields — skip any entry you can't confidently interpret rather than
failing the whole load.ready_to_propose entry from Step 2, compare its pattern description
against every suppression entry's Pattern field. If a suppression clearly
matches:
Skipping {fingerprint} — accepted as debt per duplication-decisions.md ("{pattern name}").duplication-scan uses when surveying.references/pre-filing-verification.md (relative to the plugin root) — before it
proceeds any further. The registry check above only re-verifies suppression
status; it says nothing about whether the occurrence list itself is still
accurate, since the finding is a snapshot that may already be stale by the time
this skill runs. Treat references/pre-filing-verification.md as canonical for
how to apply the checklist. Per its four checks:
file:line) in the candidate's occurrence list, verify
the file/line still exists and the duplication pattern is still actually
present there (Checklist Items 1–2). If every occurrence has been resolved or
no longer matches the described pattern, drop the candidate entirely — do not
queue a task for it. Print: Skipping {fingerprint} — stale, no remaining occurrences match the described pattern. If only some occurrences are stale,
drop those from the occurrence list and proceed with the remaining ones (the
Step 6 execution plan and Step 8 task JSON are built from the surviving
occurrences only).--dry-run preview (Step 4) and the
real queue path (Step 5 onward) operate on the same already-verified candidate
set.If --dry-run was passed, print a preview and stop without querying or writing to
the task store:
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
DUPLICATION FIX — DRY RUN
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Would queue {N} tasks:
1. duplication-{fingerprint-or-slug}-{repo-slug}-{YYYY-Www}
Pattern: {pattern description}
Occurrences: {count} sites across {list of unique file paths}
Canonical shape: {one-line summary of proposed canonical shape}
Strangler-fig steps: {count} PR-sized steps (build -> coexist -> eliminate)
Route: {auto|review|plan} (per Step 7)
2. ...
No tasks written to task store.
Re-run without --dry-run to queue tasks.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Stop after printing.
This mirrors entropy-fix's dedup mechanism (its Step 6q.1) exactly — same
queries, same filters, no new task-store schema or fields.
The repo value is the --repo argument (e.g. app-vitals/shipwright), used both
to scope the dedup queries below and, unchanged, as the task JSON's repo field in
Step 8. repo-slug was derived in Setup.
Run (URL-encode the repo, e.g. app-vitals%2Fshipwright). GET /tasks
defaults to limit=50 and truncates silently unless the caller raises it — pass an
explicit high limit=1000 on both queries:
curl -sf -H "Authorization: Bearer $SHIPWRIGHT_TASK_STORE_TOKEN" \
"$SHIPWRIGHT_TASK_STORE_URL/tasks?status=pending&repo={url-encoded-repo}&limit=1000" | jq .
curl -sf -H "Authorization: Bearer $SHIPWRIGHT_TASK_STORE_TOKEN" \
"$SHIPWRIGHT_TASK_STORE_URL/tasks?status=in_progress&repo={url-encoded-repo}&limit=1000" | jq .
The &repo= filter scopes dedup to tasks for the repo currently being scanned —
without it, a pattern active for one repo would incorrectly block or interfere with
dedup for a different repo.
Pagination guard — do not silently proceed with a partial result set. limit=1000
covers the common case, but a repo can still have more than 1000 active tasks. After each call, check the response's nextCursor: if it is null, the page is complete. If it is a string,
the first limit=1000 page did not cover every active task — re-run the same query with
&cursor=<nextCursor> (the opaque string from the previous response; never parse or build one)
and merge the .tasks arrays, repeating until nextCursor is null. Only treat the dedup
query as complete once every page has been fetched this way; never build the "already active"
set (below) from a page that fails this check.
Parse both .tasks arrays. From the combined results, collect tasks where:
source == "shipwright", ORtitle starts with "Duplication:" (this skill's title-prefix, mirroring
entropy-fix's "Entropy fix:" prefix)Extract the fingerprint (or pattern slug) from existing tasks by parsing the id
field (format: duplication-{fingerprint-or-slug}-{repo-slug}-{YYYY-Www}) or from
the branch field (format: fix/duplication-{fingerprint-or-slug}-{repo-slug}-{yyyy-www}). Build a
set of "already active" fingerprints/slugs.
For each ready_to_propose candidate: if its fingerprint (or slug) is in the
"already active" set, skip it. Print: Skipping {fingerprint} — task already active.
No new task-store schema is introduced anywhere in this skill — every field used in
Step 6's task JSON is a field the task store already supports for any other task
(id, title, source, repo, branch, layer, kind, status, hitl, description).
For each candidate that survives Steps 3 and 5, draft the canonical-shape proposal and its execution plan before building the task JSON in Step 8.
detail.proposed_shape
(written by duplication-scan) and firm it up into a
concrete interface/implementation sketch: what the single shared implementation
looks like, where it should live (an existing shared module/service if one
already fits, or a clearly-named new one), and its call signature.dev-task) doesn't bundle multiple call-site migrations into one PR.
A one-line rule of thumb: one call site (or a small batch of near-identical
ones) per PR, not "migrate everything in one branch."Every finding is routed one of three ways, per the finding-routing contract in
docs/task-store.md ("Finding routing"). There is no numeric backstop beyond the
heuristic below — no rigid file-count or line-count threshold alone forces a route,
beyond the "~5 call sites" guidance stated explicitly here. Judge each candidate on
its own facts, at runtime, using the same reading-comparison approach
duplication-scan uses to compare shapes.
The deciding question is size: a single-PR fix routes to auto or review; a strangler-fig plan spanning several PRs routes to plan.
kind: dev, status: pending, hitl: false.kind: dev, created status: blocked with blockedReason starting
needs-review: and holding the specific question for the human. Never
hitl: true; a human unblocks it via POST /tasks/{id}/unblock and agents then
execute it.plugins/shipwright/ and agent/, where a shared
abstraction needs a dependency or publishing surface that does not exist yet), or
otherwise needs architectural sequencing. Task: kind: prd, hitl: true,
description = a draft problem statement plus the finding and its strangler-fig
plan. A human runs it through /shipwright:prd or /shipwright:plan-session,
which produces the agent-executable PR tasks; the autonomous plan phase skips it
because it is hitl: true.The plan route is the only one that sets hitl: true; this skill has no credential
route.
For each remaining candidate, build a task object. Reuse the repo and repo-slug
values from Setup and Step 5. Common fields:
{
"id": "duplication-{fingerprint-or-slug}-{repo-slug}-{YYYY-Www}",
"title": "Duplication: {pattern description}",
"source": "duplication-fix",
"originKind": "cron",
"originRef": "duplication-patrol",
"repo": "<the --repo value>",
"branch": "fix/{task-id-lowercased}",
"layer": "Shared",
"description": "<occurrence list + canonical-shape proposal + strangler-fig step plan — see below>"
}
Plus the fields of the chosen route (Step 7):
{ "kind": "dev", "status": "pending", "hitl": false }
(auto)
{ "kind": "dev", "status": "blocked", "hitl": false,
"blockedReason": "needs-review: <the specific question for the human>" }
(review)
{ "kind": "prd", "status": "pending", "hitl": true }
(plan — the sole hitl: true shape)
The description field must give the executor enough context
to execute the whole migration without re-reading the finding:
Duplication patrol finding: {fingerprint} — {pattern description}
Occurrences ({count} total):
- {file_path}:{line_range} — {brief note on this instance}
{Include the full occurrence list from the finding. If there are more than 20, include the first 20 and append: "(+N more — re-run /duplication-scan to see all)"}
Proposed canonical shape:
{the firmed-up canonical-shape proposal from Step 6.1}
Strangler-fig execution plan (separate PRs, do not bundle):
1. Build — {what the canonical implementation PR contains, where it lives}
2. Coexist — {step per call site or small batch, each its own PR; note both old and new must keep passing the same tests at every step}
...
N. Eliminate — {final PR removing the old implementation(s), once every occurrence is migrated}
Fingerprint: {fingerprint} | First seen: {firstSeen} | Last seen: {lastSeen} | Route: {auto|review|plan}
The {repo-slug} segment is the last path segment of the detected repo value
(from Setup), lowercased — e.g. app-vitals/shipwright → shipwright. It
namespaces the task ID per repo so the same pattern scanned in two different repos
in the same week never collides.
The {YYYY-Www} suffix in the task ID uses ISO week format, same convention as
entropy-fix. Compute from the current date:
W: literal Wduplication-a1b2c3d4-shipwright-2026-W29fingerprint-or-slug: prefer a short prefix of the finding's fingerprint hash (e.g.
first 8 hex chars) for uniqueness; short-description: lowercase, hyphens, max 5
words from the pattern description.
/tmp/duplication-tasks-{unix-timestamp}.json as a
JSON array.curl -sf -X POST \
-H "Authorization: Bearer $SHIPWRIGHT_TASK_STORE_TOKEN" \
-H "Content-Type: application/json" \
"$SHIPWRIGHT_TASK_STORE_URL/tasks/bulk" \
--data-binary @/tmp/duplication-tasks-{unix-timestamp}.json | jq .
Record exactly one run with the recorder (not under --dry-run). Write a result file
{ "outcome": "ok" | "no_op", "metrics": { "auto": N, "review": N, "plan": N, "skipped": N, "suppressed": N } }
(no_op when nothing was queued) and post it:
bun ${CLAUDE_PLUGIN_ROOT}/scripts/cron-run-recorder.ts record \
--cron duplication-patrol --repo {org/repo} --commit {HEAD sha} \
--result /tmp/duplication-fix-result-{ts}.json
The auto, review and plan metrics count the three routes separately. Then print:
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
DUPLICATION FIX — QUEUED — {org/repo}
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
QUEUED {N} tasks ({A} auto, {R} review, {P} plan)
SKIPPED {N} candidates (already active)
SUPPRESSED {N} candidates (accepted as debt per duplication-decisions.md)
Tasks queued:
duplication-{fingerprint-or-slug}-{repo-slug}-{YYYY-Www} — {pattern description} [route: {auto|review|plan}]
...
{If any skipped:}
Skipped (already active):
{fingerprint} — task already in queue or in progress
{If any suppressed:}
Suppressed (accepted as debt):
{fingerprint} — {duplication-decisions.md entry name}
Auto tasks run through the normal dev loop; review tasks wait for a human to unblock
them; plan tasks wait for a human to run /shipwright:prd or /shipwright:plan-session.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Stop after printing — this is the sole final output.
/tasks/bulk non-2xx): log the response body and stop. Do
not retry blindly; re-running the skill is idempotent because the dedup check
will skip already-queued patterns.no_op run and stop.outcome: failed if the recorder is reachable.ready_to_propose
entries into one task./shipwright:prd (plan).id, title, source,
repo, branch, layer, kind, status, blockedReason, hitl,
description, originKind, originRef. This skill introduces no new fields.ready_to_propose finding is still un-suppressed; a human may have
added a new accepted-debt entry since the finding was promoted (Step 3)./duplication-scan --repo ...
separately first — this skill never triggers that itself.entropy-scan/
entropy-fix) and duplication patrol (duplication-scan/duplication-fix)
stay fully decoupled by explicit decision — this skill never writes an
entropy-scan rule, principles.md entry, or any cross-system reference. If a
duplication pattern seems worth graduating into a named entropy rule someday,
that requires a separate, deliberate decision outside this skill's scope.ready_to_propose
findings. Do not re-scan during a run.hitl: true only on the plan route — review tasks are created blocked with a
needs-review: reason, auto tasks are plain pending dev tasks.duplication-scan owns finding status; this skill never rewrites it.--repo org/repo is required; no agent-local state is read or written.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub app-vitals/shipwright --plugin shipwright27 skills in this plugin
/agent-readinessScore one repo against the agent-readiness catalogue (docs/readiness.md) with the deterministic scorer, post one ReadinessSnapshot and record one run. Requires --repo org/repo. No model judgment, no task creation, no repo files./canary-executionCross-cutting contract for the test-readiness pipeline. Defines how canary-eligible test code runs in two modes — `local` (boot dependencies inline, hit localhost) and `canary` (skip the boot, hit a deployed `TEST_TARGET_URL`) — via a dedicated entry point separate from the local smoke runner. Specifies eligibility rules (read-only or self-cleaning, smoke/E2E only, critical/high tier only, zero DB-dependent tests) and the deploy-gate budget (<60s wall time). Referenced by the inventory, system-design, migration, and roadmap skills.
/duplication-scanDiscover emerging duplicate/similar code patterns in one repo via judgment-driven comparison, track them across runs in the task store's PatrolFinding ledger, and list only stabilized open patterns in docs/patrols/duplication.md. Requires --repo org/repo. Report only — no code changes./entropy-fixRead the entropy-scan handoff for one repo and route PR-worthy violations as task-store tasks (auto / review / plan), one task per rule. Requires --repo org/repo and /entropy-scan to have run first./entropy-scanScan one repo for principle deviations and write docs/patrols/entropy.md. Requires --repo org/repo. Report only — no code changes./environments-fixRoute a repo's environment readiness findings as task-store tasks (auto / review / plan), one task per check, and record the patrol run. Requires --repo org/repo and /environments-scan first. Flags: --dry-run (preview without queueing or recording).Other plugins' skills for the same job