How-To: Diagnose and Self-Heal Backlog Health
This guide explains how to audit and automatically resolve structural backlog drift, broken dependency references, ghost index entries, and unindexed task files using spec-ops queue doctor.
Auditing Backlog Defects
As autonomous agents and human developers create, complete, and branch tasks across git worktrees, structural drift can occur. To run a proactive diagnostic health audit across docs/project/backlog/:
uv run spec-ops queue doctor
(Note: spec-ops backlog doctor is also supported as an alias.)
Defects Detected by Doctor
- Broken & Dangling Dependencies: Tasks declaring dependencies in frontmatter (
dependencies: [...]) that do not exist anywhere on disk incomplete/,refined/, orproposed/. The exact file and line number are reported. - Ghost Index References: Entries in
PRIORITY.mdpointing to tasks or file paths that have been deleted or moved. - Unindexed Task Files: Task files present on disk in
complete/,refined/, orproposed/that are omitted fromPRIORITY.md. - Status & Folder Drift: Discrepancies between a task's disk folder (e.g.
refined/vsproposed/) and its entry inPRIORITY.md. - Broken Relative Links: Markdown links between backlog documents that point to non-existent target files.
Automated Self-Healing Repair
To automatically repair detected discrepancies in-place:
uv run spec-ops queue doctor --fix
(Note: --repair is also accepted as an alias for --fix.)
Repair Actions Performed
- Clean Dangling Dependencies: Atomically removes non-existent task IDs from frontmatter
dependenciesin task files while preserving valid dependencies, titles, and body content. - Clean Ghost Entries: Strips deleted task references from
PRIORITY.md. - Append Unindexed Tasks: Deterministically indexes orphan task files at the end of
PRIORITY.mdsorted by task number under their corresponding status. - Synchronize Status Drift: Updates
PRIORITY.mdstatus tags and folder paths to reflect disk reality.
Machine-Readable JSON Telemetry
For CI pipelines and automated preflight scripts, the doctor supports structured JSON output:
uv run spec-ops queue doctor --json
Output format:
{
"is_healthy": true,
"issues_count": 0,
"remediated_count": 0,
"remediations": [],
"defects": []
}