<!-- swain-model-hint: sonnet, effort: low — default for task management; see per-section overrides below -->
Execution Tracking
Abstraction layer for agent execution tracking. Other skills (e.g., swain-design) express intent using abstract terms; this skill translates that intent into concrete CLI commands.
Before first use: Read skills/swain-do/references/tk-cheatsheet.md for complete command syntax, flags, ID formats, and anti-patterns.
Artifact handoff protocol
This skill receives handoffs from swain-design based on a four-tier tracking model:
| Tier | Artifacts | This skill's role |
|---|
| Implementation | SPEC | Create a tracked implementation plan and task breakdown before any code is written |
| Coordination | EPIC, VISION, JOURNEY | Do not track directly — swain-design decomposes these into children first, then hands off the children |
| Research | SPIKE | Create a tracked plan when the research is complex enough to benefit from task breakdown |
| Reference | ADR, PERSONA, RUNBOOK | No tracking expected |
If invoked directly on a coordination-tier artifact (EPIC, VISION, JOURNEY) without prior decomposition, defer to swain-design to create child SPECs first, then create plans for those children.
Term mapping
Other skills use these abstract terms. This skill maps them to the current backend (
):
| Abstract term | Meaning | tk command |
|---|
| implementation plan | Top-level container grouping all tasks for a spec artifact | tk create "Title" -t epic --external-ref <SPEC-ID>
|
| task | An individual unit of work within a plan | tk create "Title" -t task --parent <epic-id>
|
| origin ref | Immutable link from a plan to the spec that seeded it | flag on epic creation |
| spec tag | Mutable tag linking a task to every spec it affects | on create |
| dependency | Ordering constraint between tasks | (child depends on parent) |
| ready work | Unblocked tasks available for pickup | |
| claim | Atomically take ownership of a task | |
| complete | Mark a task as done | tk add-note <id> "reason"
then |
| abandon | Close a task that will not be completed | tk add-note <id> "Abandoned: <why>"
then |
| escalate | Abandon + invoke swain-design to update upstream artifacts | Abandon, then invoke swain-design skill |
Configuration and bootstrap
Config stored in
.agents/execution-tracking.vars.json
(created on first run). Read
references/configuration.md for first-run setup questions, config keys, and the 6-step bootstrap workflow.
Statuses
tk accepts exactly three status values:
,
,
. Use the
command to set arbitrary statuses, but the dependency graph (
,
) only evaluates these three.
To express abandonment, use
tk add-note <id> "Abandoned: ..."
then
— see
Escalation.
Operating rules
- Always include (or ) when creating issues — a title alone loses the "why" behind a task. Future agents (or your future self) picking up this work need enough context to act without re-researching.
- Create/update tasks at the start of work, after each major milestone, and before final response — this keeps the tracker useful as a live dashboard rather than a post-hoc record.
- Keep task titles short and action-oriented — they appear in output, tree views, and notifications where space is limited.
- Store handoff notes using
tk add-note <id> "context"
rather than ephemeral chat context — chat history is lost between sessions, but task notes persist and are visible to any agent or observer.
- Include references to related artifact IDs in tags (e.g., ) — this enables querying all work touching a given spec.
- Prefix abandonment reasons with when closing incomplete tasks — this convention makes abandoned work findable so nothing silently disappears.
- Use for structured output — when you need JSON for programmatic use, pipe through (available in the vendored directory) instead of parsing human-readable output. Example:
ticket-query '.status == "open"'
<!-- swain-model-hint: opus, effort: high — plan creation and code implementation require deep reasoning -->
TDD enforcement
Strict RED-GREEN-REFACTOR with anti-rationalization safeguards and completion verification. Read references/tdd-enforcement.md for the anti-rationalization table, task ordering rules, and evidence requirements.
Spec lineage tagging
Use
on plan epics (immutable origin) and
on child tasks (mutable). Query:
ticket-query '.tags and (.tags | contains("spec:SPEC-003"))'
. Cross-plan links:
tk link <task-a> <task-b>
.
Escalation
When work cannot proceed as designed, abandon tasks and escalate to swain-design. Read references/escalation.md for the triage table, abandonment commands, escalation workflow, and cross-spec handling.
"What's next?" flow
Run
for unblocked tasks and
ticket-query '.status == "in_progress"'
for in-flight work. If
is empty or missing, defer to
bash "$(find "$(git rev-parse --show-toplevel 2>/dev/null || pwd)" -path '*/swain-design/scripts/chart.sh' -print -quit 2>/dev/null)" ready
for artifact-level guidance.
Context on claim
When claiming a task tagged with
, show the Vision ancestry breadcrumb to provide strategic context. Run
bash "$(find "$(git rev-parse --show-toplevel 2>/dev/null || pwd)" -path '*/swain-design/scripts/chart.sh' -print -quit 2>/dev/null)" scope <SPEC-ID> 2>/dev/null | head -5
to display the parent chain. This tells the agent/operator how the current task connects to project strategy.
Artifact/tk reconciliation
When specwatch detects mismatches (
,
in
), read
references/reconciliation.md for the mismatch types, resolution commands, and reconciliation workflow.
Session bookmark
After state-changing operations, update the bookmark:
bash "$(find . .claude .agents -path '*/swain-session/scripts/swain-bookmark.sh' -print -quit 2>/dev/null)" "<action> <task-description>"
Superpowers skill chaining
When superpowers is installed, swain-do must invoke these skills at the right moments — do not skip them or inline the work:
-
Before writing code for any task: Invoke the
skill. Write a failing test first (RED), then make it pass (GREEN), then refactor. This applies to every task, not just the first one.
-
When dispatching parallel work: Invoke
subagent-driven-development
(if subagents are available and tasks are independent) or
(if serial). Read
references/execution-strategy.md for the decision tree.
-
Before claiming any task or plan is complete: Invoke
verification-before-completion
. Run the verification commands, read the output, and only then assert success. No completion claims without fresh evidence.
Detection: ls .agents/skills/test-driven-development/SKILL.md .claude/skills/test-driven-development/SKILL.md 2>/dev/null
— if at least one path exists, superpowers is available. Cache the result for the session.
When superpowers is NOT installed, swain-do uses its built-in TDD enforcement (see references/tdd-enforcement.md) and serial execution.
Plan ingestion (superpowers integration)
When a superpowers plan file exists, use the ingestion script (
skills/swain-do/scripts/ingest-plan.py
) instead of manual task decomposition. Read
references/plan-ingestion.md for usage, format requirements, and when NOT to use it.
Execution strategy
Selects serial vs. subagent-driven execution based on superpowers availability and task complexity. Read references/execution-strategy.md for the decision tree, detection commands, and worktree-artifact mapping.
Pre-plan implementation detection
Before creating a plan for a SPEC, check whether it is already implemented. Perform all three steps:
Step 1 — Check git history for the spec ID:
bash
git log --oneline --all | grep -i "<SPEC-ID>"
Matching commits are a strong signal.
Step 2 — Check whether deliverable files exist:
Read the spec artifact to identify described deliverables (files, scripts, configs). Check whether those files exist using
or
.
Step 3 — Re-run tests fresh (REQUIRED if tests are mentioned in the spec):
Do NOT trust any prior claim or cached result. Run the tests now and read the actual output. This is the critical evidence gate.
Decision:
- 2 or more signals confirm implementation → offer the retroactive-close path (below)
- 1 signal → proceed with normal plan creation; note the signal in the first task's description
- 0 signals → proceed normally
Retroactive-close path:
- Do NOT create a full task decomposition.
- Create a single tracking task:
tk create "Retroactive verification: <SPEC-ID>" -t task --external-ref <SPEC-ID>
- Claim it:
- Run
verification-before-completion
(if superpowers installed) or re-run the spec's tests manually.
- If verification passes: add a note with the evidence, close the task, then invoke swain-design to transition the spec to Complete.
- If verification fails: fall back to normal plan creation — the prior implementation was incomplete.
Anti-rationalization safeguard (CRITICAL):
The agent MUST re-run tests during detection — it cannot assume prior passing results are current. "Tests passed before" or "I implemented this earlier" is NOT evidence. Fresh test execution output is evidence.
Worktree isolation preamble
Before any implementation or execution operation (plan creation, task claim, code writing, execution handoff), run this detection:
bash
GIT_COMMON=$(git rev-parse --git-common-dir 2>/dev/null)
GIT_DIR=$(git rev-parse --git-dir 2>/dev/null)
[ "$GIT_COMMON" != "$GIT_DIR" ] && IN_WORKTREE=yes || IN_WORKTREE=no
Read-only operations (
,
, status checks, task queries) skip this check entirely — proceed in the current context.
If : already isolated. Proceed normally.
If (main worktree) and the operation is implementation or execution:
-
Use the
tool to create an isolated worktree. This is the only mechanism that actually changes the agent's working directory — manual
+
does not persist across tool calls.
-
After entering, re-run tab naming to reflect the new branch:
bash
REPO_ROOT="$(git rev-parse --show-toplevel 2>/dev/null || pwd)"
bash "$REPO_ROOT/skills/swain-session/scripts/swain-tab-name.sh" --path "$(pwd)" --auto
-
If
fails — stop. Surface the error to the operator. Do not begin implementation work.
Note: swain-session auto-enters a worktree at startup (Step 1.5), so this preamble is a fallback for sessions that skipped isolation or where the operator exited the worktree mid-session.
When all tasks in the plan complete, or when the operator requests, call
to return to the main checkout.
Fallback
If
cannot be found or is unavailable:
- Log the failure reason.
- Fall back to a neutral text task ledger (JSONL or Markdown checklist) in the working directory.
- Use the same status model (, , , ) and keep updates externally visible.