From smith
Automates bug fixes and small code changes autonomously from invocation to merged PR. No questions gate, spec generation, or planning—for quick, well-defined updates in 1-3 files.
npx claudepluginhub attckdigital/smithThis skill uses the workspace's default tool permissions.
A streamlined alternative to `/smith-new` for bugs, small changes, and trivial fixes that don't require requirements gathering, planning, or a questions gate. Runs fully autonomously from invocation to merged PR.
Orchestrates bug-fixing workflow: clarify symptoms, reproduce with failing tests, diagnose root cause, implement targeted fixes, verify, review, and document. Use for thorough bug investigations.
Executes autonomous build pipeline: generates tasks, implements code, tests, commits, pushes to branch, creates/merges PRs, and generates release notes without user interaction.
Share bugs, ideas, or general feedback.
A streamlined alternative to /smith-new for bugs, small changes, and trivial fixes that don't require requirements gathering, planning, or a questions gate. Runs fully autonomously from invocation to merged PR.
Arguments: $ARGUMENTS
Throughout this action, log significant events to the vault session log. Read the session log path from .smith/vault/.current-session. If the file is missing or the vault is not initialized, skip all logging silently.
Append entries using this format:
### [HH:MM:SS] /smith-bugfix <event>
**User Request:**
> <verbatim user message that triggered this action — capture the exact words the user typed describing the bug or fix needed. For natural language triggers like "fix this", include the preceding context that describes what's broken.>
**Synthesized Input:** <brief summary of the fix being applied>
**Outcome:** <what happened>
**Artifacts:** <files created/modified>
**Systems affected:** <system IDs>
Log at these points:
Immediately before every Agent tool call in this workflow, append a block to the session log. The Agent tool's return value does not expose subagent_type or model to the parent, so this is the only place that information can be captured.
### [HH:MM:SS] Subagent invoked: <description>
**Type:** <subagent_type or "general">
**Model:** <model override passed to Agent, or "inherited" if none>
After the Agent tool returns, the subagent-vault-writeback.sh hook automatically appends a matching "Subagent completed" block with metrics read from the sidechain transcript — do not duplicate that logging in the skill.
/smith-new)Use /smith-bugfix when:
Upgrade to /smith-new if during implementation you discover:
If upgrading: STOP, tell the user, and offer to switch to /smith-new with the context gathered so far.
If the user says any of the following (or similar phrases), treat it as invoking this command:
When triggered by natural language, synthesize the conversation history into a concise bug/fix description and proceed as if that description was passed as $ARGUMENTS.
Every bugfix always runs in an isolated git worktree branched from origin/main. The user's current working directory and branch are NEVER touched, and concurrent Smith sessions cannot collide on the shared working tree. There is no "switch to main / stash / cancel" branching logic — the worktree is mandatory.
Generate fix slug (2-4 words) from the fix description. Store as $SLUG. Derive:
BRANCH=fix/$SLUGWORKTREE_PATH=/tmp/smith-bugfix-$SLUGPRIMARY_REPO=<current working directory — capture before entering the worktree>Fetch latest main (does NOT change the user's current branch):
git fetch origin main
Activate workflow tracking — create a per-branch file in .smith/vault/active-workflows/ in the primary repo (not the worktree, which doesn't exist yet):
SAFE_BRANCH=$(echo "$BRANCH" | sed 's/[^a-zA-Z0-9._-]/-/g')
mkdir -p .smith/vault/active-workflows
cat > .smith/vault/active-workflows/${SAFE_BRANCH}.yaml << EOF
workflow: smith-bugfix
feature: $SLUG
branch: $BRANCH
worktree: $WORKTREE_PATH
started: $(date -u +"%Y-%m-%dT%H:%M:%S")
EOF
If a yaml file with the same SAFE_BRANCH already exists, another session is already using that branch — pick a new slug (e.g., append -2) and retry. The file is cleared by the Workflow Cleanup step at the end.
Create the worktree with the fix branch from origin/main:
git worktree add "$WORKTREE_PATH" -b "$BRANCH" origin/main
The user's current branch is completely unaffected. They can be on main, a feature branch, or a detached HEAD — this workflow will not interfere.
Copy .env to the worktree (only if one exists in the primary repo and the fix might touch services that read it):
[ -f .env ] && cp .env "$WORKTREE_PATH/.env"
All subsequent phases (2-7) run inside $WORKTREE_PATH. Use cd "$WORKTREE_PATH" for the first command, then keep every subsequent command scoped to that directory via absolute paths or explicit cd. Do NOT cd back to the primary repo until Phase 7.3 (merge) — gh pr merge must run from the primary repo to avoid "main already checked out" errors.
On failure before merge: preserve the worktree for debugging and log its path in the session log. Do NOT auto-remove it. Leave the active-workflow yaml in place so the user knows the session is still holding that branch.
If .smith/vault/ledger/ exists and contains non-empty files, load relevant Ledger sections to inform this bugfix. If the directory is missing, empty, or unreadable, skip silently — the Ledger is purely additive and never required.
ls .smith/vault/ledger/*.md 2>/dev/null.smith/vault/ledger/antipatterns.md.smith/vault/ledger/edge-cases.mdcontext_budget_violations in .smith/vault/ledger/.meta.json by 1. If .meta.json does not exist, create it from the default template first. This signal tells the reconciliation system that the Ledger is too large for the configured budget.Before writing any code, check existing specs for context and conflicts.
Identify affected systems from the fix description and map to spec directories:
services/command-center/ → specs/system-15-command-center/spec.mdservices/email-pipeline/ → specs/system-03-email-archive-contact-graph/spec.mdservices/sentiment-engine/ → specs/sentiment-engine/spec.mdservices/communication-triage/ → specs/system-05-communication-triage/spec.mdservices/voice-training/ → specs/system-04-personal-voice/spec.mddocker-compose.yml → specs/system-01-core-infrastructure/spec.mdspecs/*/spec.md contentRead relevant spec.md files and check:
If a conflict is found: STOP the workflow and alert the user. Explain the conflict and ask how to proceed. This is the ONLY point where the workflow may pause.
If no conflicts: Continue silently.
If the bugfix execution fails, check config for auto-retry:
.smith/config.json — check ledger.auto_retry and ledger.max_retriesauto_retry is false (default) or config is missing, do NOT retry — fail normallyauto_retry is true:
a. Re-read .smith/vault/ledger/antipatterns.md to get the latest failure patterns
b. Analyze the failure against known antipatterns to adjust the approach
c. Retry the fix with the adjusted approach
d. Repeat up to max_retries times (default: 2), re-reading antipatterns before each attempt
e. If all retries exhausted, fail with a summary of all attemptsIf any files changed belong to a Docker service:
docker compose up -d --build <service-name>
bash scripts/health-check.sh
Skip this phase if changes are limited to specs, docs, or config files that don't affect running services.
cd services/command-center && pnpm testcd services/<service> && poetry run pytestservices/command-center/src/** were modifiedcd services/command-center && pnpm exec playwright testcd services/command-center && pnpm lintcd services/<service> && poetry run ruff check .For each affected system spec.md:
If the fix is relevant to project status tracking, update STATUS.md.
git add <all modified files — list explicitly, never git add -A>
git commit -m "fix: <description>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>"
fix: conventional commit prefixgit add -A or git add .).env files or credentialsgit push -u origin fix/<slug>
gh pr create --title "fix: <short title>" --body "$(cat <<'EOF'
## Summary
<1-3 bullet points describing the fix>
## What was broken
<Brief description of the bug/issue>
## What changed
<List of files and what changed in each>
## Test plan
- [ ] Unit tests pass
- [ ] E2E tests pass (if applicable)
- [ ] Docker health check passes (if applicable)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
EOF
)"
Then merge from the primary repo directory (never from the worktree — gh pr merge fails with "main already checked out" otherwise):
cd "$PRIMARY_REPO" && gh pr merge <pr-number> --squash --delete-branch
cd "$PRIMARY_REPO" && git pull origin main
Already covered by git pull above. The user's working branch in the primary repo is untouched — only the main branch ref moves forward. If the user was on main, they now see the merged changes; if they were on another branch, main is updated but their checkout is not.
cd "$PRIMARY_REPO" && docker compose up -d --build <service-name>
cd "$PRIMARY_REPO" && bash scripts/health-check.sh
Skip if no Docker services were touched.
Emit a final chat message to the user that starts with "Bugfix complete. Here's the summary:" (or equivalent for the fix). Include any bugfix-specific notes (test results, services rebuilt, worktree path if preserved on failure). At the bottom, run bash hooks/workflow-summary.sh --totals-only (from either the primary repo or the worktree — both work) and paste the two lines it prints (Total tokens used: ~<n> and Total duration: <d>) verbatim — do this BEFORE the Workflow Cleanup step below.
The full === Workflow Summary === block is written to the session log file automatically by the workflow-summary.sh Stop hook once the active-workflow file is removed — that's for audit only, not chat. Do not emit the full block to the user.
Run from the primary repo directory. On success, remove the worktree; on failure (before merge), preserve it and skip worktree removal.
cd "$PRIMARY_REPO"
# Success path: remove the worktree (the branch was already deleted by --delete-branch on merge)
git worktree remove "$WORKTREE_PATH"
# Always: clear the active-workflow marker so future sessions know this branch is free.
# Use the shipped helper so this works even on projects that set Bash(rm:*) in the
# deny list of .claude/settings.json.
.specify/scripts/bash/clear-active-workflow.sh "$BRANCH"
If git worktree remove fails because of uncommitted local edits (shouldn't happen on the success path, but can on forced cleanup), fall back to git worktree remove --force "$WORKTREE_PATH" and warn the user that any uncommitted changes in the worktree are being discarded.
After workflow completion (success or failure), trigger a Ledger reflection if enabled:
.smith/config.json — if ledger.auto_reflect is true (default), proceed.smith/vault/ledger/ pathsmith-reflect workflow.smith/config.json is missing or ledger.auto_reflect is false, skip silentlyAfter reflection completes (or is skipped):
.smith/config.json — if ledger.reconcile.auto_reconcile is false, skip.smith/vault/ledger/.meta.json — check signals against thresholds:
estimated_tokens > thresholds.total_tokens_max (default 30000)context_budget_violations > thresholds.context_violations_threshold (default 3)reinforcements_since_reconcile > thresholds.reinforcements_threshold (default 50)last_reconcile is less than minimum_hours_between_reconciles (default 6) hours ago, skipreconcile_model (default: Haiku).meta.json is missing, or config is missing, skip silentlygit add -A or git add . — always stage specific files.env files or credentials/smith-new