From kraftwork
Archive a completed worktree — generates a searchable summary, moves specs to deep storage, and removes the worktree. Use when done with a ticket.
How this skill is triggered — by the user, by Claude, or both
Slash command
/kraftwork:kraft-archiveThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Safely archive a completed ticket: generate a searchable summary, move specs to deep storage, and remove the git worktree.
Safely archive a completed ticket: generate a searchable summary, move specs to deep storage, and remove the git worktree.
| Script | Purpose |
|---|---|
find-workspace.sh | Locate workspace root |
list-worktrees.sh | List active worktrees |
safety-check.sh | Check for uncommitted/unpushed changes |
IMPORTANT: Derive the scripts directory from this skill file's location:
kraftwork/skills/kraft-archive/SKILL.md<workspace-root>/scripts/When you load this skill, note its file path and compute the scripts directory. For example, if this skill is at /path/to/kraftwork/skills/kraft-archive/SKILL.md, then scripts are at /path/to/kraftwork/scripts/.
WORKSPACE=$(<scripts-dir>/find-workspace.sh)
If user is currently in a worktree:
WORKTREE_PATH=$(git rev-parse --show-toplevel 2>/dev/null)
TICKET_ID=$(basename "$WORKTREE_PATH" | grep -oE '^[A-Z]+-[0-9]+' || echo "")
if [ -n "$TICKET_ID" ]; then
echo "Current worktree: $WORKTREE_PATH"
echo "Ticket: $TICKET_ID"
fi
If not in a worktree or ticket ID provided as argument:
WORKTREE_PATH=$(find "$WORKSPACE/trees" -maxdepth 1 -type d -name "${TICKET_ID}-*" | head -1)
If no ticket specified, list active worktrees:
echo "Active worktrees:"
FORMAT=detail <scripts-dir>/list-worktrees.sh "$WORKSPACE"
Then ask user which to archive using AskUserQuestion.
Run safety check on the worktree:
SAFETY=$(<scripts-dir>/safety-check.sh "$WORKTREE_PATH" || true)
echo "$SAFETY" | jq .
Parse results:
HAS_UNCOMMITTED=$(echo "$SAFETY" | jq -r '.uncommitted.has_changes')
HAS_UNPUSHED=$(echo "$SAFETY" | jq -r '.unpushed.has_commits')
HAS_OPEN_PR=$(echo "$SAFETY" | jq -r '.open_pr.exists')
PR_URL=$(echo "$SAFETY" | jq -r '.open_pr.url')
If any warnings were raised, use AskUserQuestion:
Safety checks found potential issues:
- Uncommitted changes: [count] files modified
- Unpushed commits: [count] commits
- Open MR: [url]
Are you sure you want to archive this worktree?
Options:
Check if a retrospective has been run:
RETRO_FILE="$WORKSPACE/docs/lessons/${TICKET_ID}-retro.md"
if [ ! -f "$RETRO_FILE" ]; then
echo "No retrospective found for $TICKET_ID."
fi
If no retro file exists, use AskUserQuestion:
No retrospective found for $TICKET_ID. Want to run kraft-retro before archiving?
Options:
Read available inputs to synthesize a summary. If no spec directory exists (e.g., quick fix or hotfix), generate the summary from the git log and retro only.
$WORKSPACE/docs/specs/$TICKET_ID/spec.md for intent, requirements, decisions (if exists)$WORKSPACE/docs/specs/$TICKET_ID/tasks.md for planned scope (if exists)$WORKSPACE/docs/specs/$TICKET_ID/changes/ for mid-implementation pivots (if directory exists)$WORKSPACE/docs/lessons/${TICKET_ID}-retro.md for lessons and outcome (if file exists)BRANCH=$(git -C "$WORKTREE_PATH" branch --show-current)
git -C "$WORKTREE_PATH" log --oneline main..$BRANCH
Tone: factual, compressed, skimmable in 10 seconds.
Synthesize into a summary following this format:
# TICKET_ID: Short title from spec
## What changed
Brief description of the work delivered (2-4 sentences).
## Key decisions
- Decision and rationale
- Rejected alternative and why
## Areas touched
- `path/to/module/` — what was changed
- `path/to/other/` — what was changed
## Outcome
Merged via MR !number on YYYY-MM-DD. (Or: abandoned, split, etc.)
---
Archived specs: `docs/archive/TICKET_ID/`
Show the draft summary to the user before writing. If the user requests changes, revise and re-present until approved.
Write the approved summary:
mkdir -p "$WORKSPACE/docs/summaries"
Then use the Write tool to create $WORKSPACE/docs/summaries/$TICKET_ID.md.
Move the spec directory to deep storage (skip if no spec directory exists):
if [ -d "$WORKSPACE/docs/specs/$TICKET_ID" ]; then
mkdir -p "$WORKSPACE/docs/archive"
mv "$WORKSPACE/docs/specs/$TICKET_ID" "$WORKSPACE/docs/archive/$TICKET_ID"
echo "Specs archived to: $WORKSPACE/docs/archive/$TICKET_ID/"
fi
If currently inside the worktree, navigate away first:
cd "$WORKSPACE"
echo "Moved to: $(pwd)"
Remove the worktree:
BRANCH=$(git -C "$WORKTREE_PATH" branch --show-current)
GIT_DIR=$(git -C "$WORKTREE_PATH" rev-parse --git-dir)
SOURCE_REPO=$(echo "$GIT_DIR" | sed 's|/\.git/worktrees/.*|/.git|' | xargs dirname)
git -C "$SOURCE_REPO" worktree remove "$WORKTREE_PATH"
git -C "$SOURCE_REPO" worktree prune
echo "Worktree removed: $WORKTREE_PATH"
Archived TICKET_ID
Summary: docs/summaries/TICKET_ID.md
Specs: docs/archive/TICKET_ID/
Worktree: removed
Branch: still exists (local + remote)
npx claudepluginhub filipeestacio/kraftwork --plugin kraftworkGuides creation, editing, and verification of skills for AI coding agents using test-driven development with subagent scenarios. Use when authoring or debugging skills.