From code-quality
Stateful multi-plan phase sequencing, dependency analysis, and roadmap lifecycle management. Detects existing roadmaps and routes to update, cleanup, status/drift, or fresh creation. Use when coordinating multiple implementation plans into parallel/sequential workstreams, or when managing an existing roadmap. Trigger phrases: "roadmap", "sequence plans", "coordinate multiple plans", "plan execution order", "roadmap status", "roadmap cleanup", "update roadmap", "roadmap drift", or when 2+ plans need ordering.
npx claudepluginhub wgordon17/personal-claude-marketplace --plugin code-qualityThis skill is limited to using the following tools:
Stateful multi-plan phase sequencing with roadmap lifecycle management. Takes existing plan
Searches, retrieves, and installs Agent Skills from prompts.chat registry using MCP tools like search_skills and get_skill. Activates for finding skills, browsing catalogs, or extending Claude.
Searches prompts.chat for AI prompt templates by keyword or category, retrieves by ID with variable handling, and improves prompts via AI. Use for discovering or enhancing prompts.
Guides Next.js Cache Components and Partial Prerendering (PPR) with cacheComponents enabled. Implements 'use cache', cacheLife(), cacheTag(), revalidateTag(), static/dynamic optimization, and cache debugging.
Stateful multi-plan phase sequencing with roadmap lifecycle management. Takes existing plan
files as input, produces a structured roadmap document consumable by /swarm and other
orchestrators. Detects existing roadmaps and routes to update, cleanup, status/drift, or
fresh creation.
This skill activates when:
/incremental-planning generates a plan that references other planned workAnnounce at start: "Using roadmap to sequence [N] plans into phases."
Before ingesting any plans, check whether an existing roadmap document already exists.
Detect the project memory directory using the convention in
code-quality/references/project-memory-reference.md (Directory Detection section).
If found: Plan directory is {memory_dir}/plans/
If none found: Skip Phase 0 — proceed to Phase 1. Stateful roadmap management
requires a project-local memory directory. ~/.claude/plans/ is shared across all projects
and globbing it would surface cross-project roadmaps, leading to false positives and
unintended mutations.
Exception: If the user's request matches a lifecycle trigger phrase (roadmap status,
update roadmap, roadmap cleanup, roadmap drift, or similar), do NOT silently fall
through to Phase 1. Instead, surface via AskUserQuestion:
"Roadmap lifecycle management (update, cleanup, status/drift) requires a project-local memory directory (hack/, .local/, scratch/, or .dev/). This project doesn't have one. Options:
- Create a new roadmap via Phase 1 (fresh creation only — no lifecycle features)
- Abort"
Scope the glob strictly to the determined plan directory — do not glob the project root or any other location. This prevents false positives from unrelated files.
Glob for *roadmap*.md within the plan directory only.
For each match, verify it is an actual roadmap document by checking for both:
# Roadmap: header (first-level heading starting with "Roadmap:")**Source plans:** field in the document header blockDiscard any matches that lack either marker (e.g., a plan file about improving the roadmap skill). If no verified roadmaps remain → skip to Phase 1 (existing flow, unchanged).
If more than one verified roadmap is found, first ask which one to operate on:
AskUserQuestion: "I found [N] roadmap files in [plan-dir]:
1. [filename-1] — [title from # Roadmap: header]
2. [filename-2] — [title from # Roadmap: header]
Which roadmap do you want to work with?"
Proceed with the selected roadmap for the remainder of Phase 0.
From the selected roadmap, extract:
# Roadmap: heading**Source plans:** field (list of plan file paths)**Total phases:** fieldPresent a AskUserQuestion with four options:
AskUserQuestion: "Found existing roadmap: [title]
Source plans: [N] plans | Total phases: [M]
What would you like to do?
1. Update existing roadmap — re-ingest all plans (including any new ones) and regenerate
2. Clean up completed work — archive done plans and remove merged branches
3. Show status / drift report — see per-phase completion and drift detection (read-only)
4. Create new roadmap (ignore existing) — start fresh with Phase 1"
Based on the user's selection:
| Choice | Routes to |
|---|---|
| Update existing roadmap | Phase 0.U (below) — re-ingest with completion awareness |
| Clean up completed work | Phase 0.C (below) — archive and branch removal |
| Show status / drift report | Phase 0.S (below) — read-only status and drift report |
| Create new roadmap | Phase 1 — existing flow, existing roadmap is left untouched |
Executes when user selects "Update existing roadmap."
**Source plans:** list to get all already-ingested plan paths.AskUserQuestion:
"The existing roadmap covers [N] source plans. Do you have new plan files to add? Provide paths, or press Enter to re-sequence existing plans only."
{plan-dir}/done/{filename}.YYYY-MM-DDTHH-MM-SS.pre-update (timestamped, unique per run)
before writing the regenerated version. Create {plan-dir}/done/ if it doesn't exist.
The hack/ directory is gitignored — an explicit backup is the only recovery path.**Last updated:** with the current ISO timestamp
(e.g., 2026-03-20T14:30:00) in the document header.Edge cases:
AskUserQuestion:
"Plan [path] no longer exists. Remove from roadmap, or provide an updated path?"roadmap/phase-2/plan-x) would be affected, surface via
AskUserQuestion:
"Phase restructuring would affect in-progress branch [roadmap/phase-2/plan-x]. Options:
(1) Rename the branch to match the new structure, (2) Keep current phase structure for
in-progress work and only re-sequence not-started phases, (3) Abandon in-progress branch
and start fresh."
Default to option 2 (least disruptive).Executes when user selects "Clean up completed work."
"Phases 1-2 complete. Phase 3 in progress. Cleanup actions available for completed phases."
AskUserQuestion and require
explicit confirmation:
"Cleanup will:
- Archive source plans for Phase 1: [plan-a.md, plan-b.md] → {plan-dir}/done/
- Archive source plans for Phase 2: [plan-c.md] → {plan-dir}/done/
- Delete local branches: roadmap/phase-1/plan-a, roadmap/phase-1/plan-b, roadmap/phase-2/plan-c
- Add 'Status: Completed' to Phase 1 and Phase 2 blocks in the roadmap document Proceed?"
"Also delete these branches from origin? (This affects shared state — confirm per session)"
**Status:** Completed to each cleaned-up phase
block (non-destructive — preserves phase content for reference).Partial cleanup guidance:
**Status:** Completed to the document header (not just
per-phase blocks), then offer to archive the entire roadmap file itself:
"All phases are complete. Archive the roadmap file to {plan-dir}/done/ as well?" If the user confirms, update the document header
**Status:**toArchivedbefore moving the file to{plan-dir}/done/.
Branch deletion scoping: Only delete branches matching roadmap/phase-N/ for the
specific completed phase numbers. Do NOT delete branches for in-progress or not-started
phases — filter by exact phase number, not a broad roadmap/* pattern.
After cleanup completes, announce: "Cleanup complete. [N] plans archived, [M] branches deleted, [P] phase blocks marked Completed." If not all phases were cleaned up, note which phases remain active.
Executes when user selects "Show status / drift report." This mode is read-only — it never mutates files or branches.
Status report:
Phase 1: Completed (2/2 tracks merged, all tasks validated)
Phase 2: In Progress (Track A merged, Track B in-progress)
Phase 3: Not Started (blocked by Phase 2)
partial or deferred tasks, list the specific tasks and their status.Drift detection (shown alongside status):
**Last updated:** field, parse its ISO timestamp as the reference time. Otherwise, use
the roadmap file's mtime via
Bash(uv run python3 -c "import os; print(os.path.getmtime('[file]'))") (portable across
macOS and Linux). For each source plan, compare its mtime against the reference time. If a source
plan is newer, flag: "Plan [path] was modified after this roadmap was generated."
On mtime anomaly (plan appears newer but changes unclear), fall back to content comparison:
read both the plan and the roadmap's corresponding plan reference and diff to confirm
whether real changes exist.*.md in the plan directory that are NOT in the
roadmap's source plans list AND are not the roadmap file itself. Flag only files that:
(a) appear to be incremental-planning output (contain **Goal:** and ## Task N: markers)
AND (b) were created after the roadmap was generated (mtime comparison). This filtering
prevents false positives from old completed plans or non-plan files.
Flag: "New plan [path] not included in this roadmap."git branch | grep roadmap/ for any roadmap/phase-*
branches that don't match any track in the current roadmap. Flag:
"Orphaned branch [name] not in current roadmap (may be from a previous or renamed roadmap)."Follow-up actions:
After presenting the report, offer via AskUserQuestion:
Read all provided plan files and extract semi-structured data. If plan paths are not
provided, use AskUserQuestion to ask for them before proceeding.
For each plan, extract:
**Goal:** line in the plan headerFor task-level extraction:
## Task N: heading pattern to identify tasks**Files:** block within each task to identify which files that task touchesIf a plan doesn't follow incremental-planning's format (missing **Goal:**, no ## Task N:
headings, no **Files:** blocks), use AskUserQuestion to surface what's missing. Offer
best-effort extraction or skip. Do not silently proceed.
After all plans are ingested and conformance-checked, check if any address open bugs.
Detect or reuse the memory directory (using the convention in
code-quality/references/project-memory-reference.md). If Phase 0 was skipped (no
project-local memory directory exists), skip this check entirely — proceed to
### Chat output.
{memory_dir}/BUGS.md exists**Status:** of Investigating,
Root Cause Found, or Fix Ready## File Structure section (tables and lists) and **Files:** blocks within tasks,
deduplicate into a single working set. Then, for each open bug entry that has a
### Files Involved section AND whose **Tracked In:** is currently — (or the
field is missing entirely — backward compatibility), compare those paths against
this aggregated file set. Strip :NN line number suffixes from BUGS.md paths before
comparing (e.g., src/auth/login.ts:42 becomes src/auth/login.ts). Match using
this precedence: exact file match (strongest signal); or common directory prefix of
at least 3 components (e.g., code-quality/skills/fix/) — prefixes
of 1 or 2 components are too broad and do not count. Skip entries without
### Files Involved (investigation may not be complete) and entries with existing
Tracked In values.**Tracked In:** yet — phase grouping is not determined until Phase 3)If no BUGS.md exists, no untracked entries, or no overlaps are found, skip silently.
If overlaps ARE found, add a separate line after the existing Phase 1 chat output:
"N untracked BUGS.md entries overlap with ingested plans: BUG-001, BUG-003."
After ingesting all plans:
"Ingested N plans. Total tasks: M. Key file overlaps: [list files touched by 2+ plans, or 'none detected']."
Identify relationships between plans and tasks that constrain execution order.
For each pair of plans:
Use mcp__sequential-thinking__sequentialthinking (or extended thinking if unavailable) to reason:
Produce a dependency edge list in your working notes (not necessarily shown to user):
Plan A Tasks 1-2 → Plan B (Plan B needs the interface defined by Plan A Tasks 1-2)
Plan C → Plan A (Plan C reads files created by Plan A's tasks)
If no dependencies are found: all plans are independent → proceed to single-phase grouping.
Group plans (or task ranges) into phases that respect the dependency edges.
For each phase:
references/phase-schema.md:
roadmap/phase-N/plan-nameAfter constructing phase groupings but before writing the document, use AskUserQuestion:
"I've organized [N] plans into [M] phases. Phase 1 runs [tracks] in parallel. Phase 2 requires Phase 1 to complete first. Does this grouping make sense, or should I adjust?"
Options:
Write the roadmap file following the schema in references/phase-schema.md.
Use the same logic as /incremental-planning:
code-quality/references/project-memory-reference.md (Directory Detection section).{memory_dir}/plans/{run-id}-roadmap-<name>.md
(create the plans/ subdirectory if it doesn't exist)~/.claude/plans/{run-id}-roadmap-<name>.mdAnnounce location: "Roadmap file: hack/plans/feat-auth-1711388400-roadmap-auth-launch.md"
Do NOT create a hack/ directory if one doesn't exist.
Write incrementally, one phase block at a time:
Write the document header (title, source plans, total phases, critical path)
For each phase, write the complete phase block (table + sync point + merge order)
After all phases are written, if Phase 1's BUGS.md cross-reference identified
overlapping entries, update those BUGS.md entries now: for each matching BUG ID,
determine which phase its overlapping plan was assigned to, then set **Tracked In:**
to Roadmap: plans/{roadmap-filename}.md (Phase N) — where {roadmap-filename} is
the filename determined by the "Determine roadmap file location" step at the start of
Phase 4 (the filename of the single roadmap output file being generated by this task,
e.g., feat-auth-1711388400-roadmap-auth-launch.md), the path is relative to the
memory directory, and N is the assigned phase number. If an entry's
**Tracked In:** already has a non-dash value, skip it. If the entry lacks a
**Tracked In:** field entirely (backward compatibility), insert the field after
**Impact:** or **Severity:**.
Chat output after step 3: If any entries were updated:
"Updated Tracked In for N BUGS.md entries: BUG-001 → Phase 2, BUG-003 → Phase 1."
Chat output per phase written:
"Phase N written: [one sentence summary]. [M] parallel tracks."
Do not write all phases at once.
After all phases are written:
AskUserQuestionComplete with:
"Roadmap complete. N phases, M total tracks. Critical path: [description]. Roadmap file: [absolute path]."
Used by Phase 0.U (update), Phase 0.C (cleanup), and Phase 0.S (status/drift) to determine the completion state of each phase and track. Run this logic whenever any mode needs phase status before acting.
For each track in each phase, determine status using the following strategy. Try the primary method first; fall back if gh is unavailable or unauthenticated.
Primary method (requires gh auth and network access):
gh pr list --state merged --head roadmap/phase-N/plan-name --json number,mergedAt
Works regardless of merge strategy (merge commit, squash, or rebase). If this returns a
result, the track is merged.
Fallback method (no network / no gh auth):
# True merges
git branch --merged main | grep roadmap/phase-N/plan-name
# Squash merges (only works if PR title or commit message contains the branch path)
git log --oneline main | grep 'roadmap/phase-N/plan-name'
Caveat: GitHub's default squash commit message uses the PR title, not the branch name.
The git log grep only works if the PR title or commit message contains the branch path.
If neither fallback detects a merge, surface via AskUserQuestion:
"Cannot determine if [branch] was merged. Was this PR squash-merged with a different commit message? Provide the PR number or commit SHA to confirm."
Track status enum:
| Status | Condition |
|---|---|
not-started | Branch roadmap/phase-N/plan-name does not exist locally or remotely |
in-progress | Branch exists but no merged PR found |
merged | PR merged (via gh) or branch content detected on main (via git fallback) |
For each track with merged status, spawn a general-purpose agent (not Explore — the
validator needs Bash for git commands, Read, and Grep) with this prompt:
"Read the plan at [plan-path], tasks [task-range]. Find what the branch changed: First try
gh pr list --state merged --head roadmap/phase-N/plan-name --json numberto get the PR number, thengh pr diff <number>for the full diff. If gh is unavailable, find the merge/squash commit viagit log --oneline main | grep 'phase-N/plan-name'and diff withgit diff <sha>~1..<sha>. For each task, verify: (1) the files listed in Files: exist on main, (2) the diff shows changes consistent with the task's described steps (not just the file existing from before), (3) no task requirements were silently deferred or left as TODOs in the merged code. Report for each task: task number, status (implemented / partial / deferred), and a one-sentence evidence summary citing specific file paths or code locations — do NOT echo raw diff content."
Important: The subagent MUST NOT echo raw diff content to chat output (security constraint — diffs may contain sensitive content). The validator returns structured verdicts only: task number, status, evidence summary.
Parallel spawning: Spawn subagent validators for all merged tracks in a phase simultaneously — they perform independent reads and can run in parallel.
A phase is Completed only when:
merged status, ANDimplemented for every taskIf any track is in-progress or not-started → phase is In Progress or Not Started.
If all tracks are merged but any task is partial or deferred → phase is Incomplete
(all branches merged but not all tasks fully implemented — distinct from In Progress where
branches are still open).
When subagent validation finds partial or deferred tasks, surface via AskUserQuestion:
"Phase [N] track [name]: Task [M] is [partial/deferred]. Evidence: [one-sentence summary]. Options:
- Create a follow-up plan for the deferred work
- Mark as intentionally deferred (acknowledge and proceed)
- Re-open the phase for remediation"
Trivial roadmap: one phase, one track. Still useful for documenting worktree isolation and the execution skill to use. Write it — don't skip.
Single phase with N parallel tracks. Skip dependency analysis (Phase 2) and go straight to track assignment. Note in roadmap header: "No dependencies detected — all plans run in parallel."
Surface immediately via AskUserQuestion:
"I found a circular dependency: Plan A depends on Plan B, and Plan B depends on Plan A (via [specific files/tasks]). I cannot resolve this automatically. Options:
- Break the cycle by extracting the shared work into a new prep task
- Manually specify which plan should run first and accept the merge conflict
- Re-examine whether the dependency is real"
Do not write a roadmap document until the cycle is resolved.
Skip it and note in the roadmap document header:
Skipped plans:
/path/to/plan.md— no## Task N:headings found.
If a plan is missing **Goal:**, no ## Task N: headings, or no **Files:** blocks, use
AskUserQuestion listing exactly what's missing. Offer:
Phase 0: Detect & Route (HITL, requires project memory dir) →
[New] Phase 1 → Phase 2 → Phase 3 (checkpoint) → Phase 4 (incremental) → Phase 5
[Update] Completion Check → Phase 1-5 (re-ingest, completed phases preserved)
[Status] Completion Check → Drift Detection → Report → offer Update/Cleanup/Exit
[Cleanup] Completion Check → Archive plans → Delete branches → Update roadmap doc
[No memory dir] → skip Phase 0, go to Phase 1 (lifecycle requests get AskUserQuestion first)
CHAT: Mode routing, ingest summary, dependency edges, checkpoint questions,
per-phase write confirmations, status/drift report, completion validation verdicts
FILE: Full roadmap document (header + phase blocks, optional Status/Last updated fields)
NEVER IN CHAT: Full roadmap content, raw table data, raw diff content from subagent validators
1. {memory_dir}/plans/{run-id}-roadmap-<name>.md → if memory dir exists (detect per project-memory-reference.md)
2. ~/.claude/plans/{run-id}-roadmap-<name>.md → fallback for all other cases
Phase 0 detection only runs when a project memory dir exists (option 1 above).
Projects using ~/.claude/plans/ skip Phase 0 and go straight to Phase 1.
references/phase-schema.md — canonical schema for all roadmap document fields,
including per-track table columns and worktree branch naming.