Help us improve
Share bugs, ideas, or general feedback.
From lavra
Guides implementation of a single bead in Lavra's workflow, including clarification, knowledge recall, and phased implementation with state machine. Invoked when working on exactly one bead.
npx claudepluginhub roberto-mello/lavra --plugin lavraHow this skill is triggered — by the user, by Claude, or both
Slash command
/lavra:lavra-work-singleThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Used when exactly one bead is being worked on. Full-quality interactive flow with built-in review, fix loop, and learn phases.
Orchestrates parallel work across multiple beads (M1-M10): gathers bead details, validates IDs, creates working branches, and dispatches subagents with conflict detection and wave ordering.
Guides using Beads (bd) distributed git-backed issue tracker for task management, dependency tracking, AI agent workflows, and multi-branch parallel development.
Guides using Beads (bd), a distributed git-backed graph issue tracker for managing tasks, tracking dependencies, AI agent workflows, and multi-branch git development.
Share bugs, ideas, or general feedback.
Used when exactly one bead is being worked on. Full-quality interactive flow with built-in review, fix loop, and learn phases.
State machine: IMPLEMENTING -> REVIEWING -> FIXING -> RE_REVIEWING -> LEARNING -> DONE
<project_root>
All .lavra/ paths are relative to the project root. PROJECT_ROOT may be injected into your context — use it if set. If not, resolve it once and reuse:
PROJECT_ROOT="${PROJECT_ROOT:-$(git rev-parse --show-toplevel 2>/dev/null || echo "$PWD")}"
Then prefix all .lavra/ paths with "$PROJECT_ROOT/" when invoking them via Bash.
</project_root>
Read Bead and Clarify
If a bead ID was provided:
bd show {BEAD_ID} --long
Read the bead description completely including:
If the bead has a parent epic, also read the epic's decision sections:
bd show {BEAD_ID} --json | jq -r '.[0].parent // empty'
# If parent exists:
bd show {PARENT_EPIC_ID}
Extract ## Locked Decisions, ## Agent Discretion, and ## Deferred sections. Locked = must honor. Discretion = deviation budget. Deferred = do NOT implement (these are explicitly out of scope).
If a specification path was provided instead:
bd create "{title from spec}" -d "{spec content}" --type taskClarify ambiguities:
Recall Relevant Knowledge (required -- do not skip)
PROJECT_ROOT="${PROJECT_ROOT:-$(git rev-parse --show-toplevel 2>/dev/null || echo "$PWD")}"
"$PROJECT_ROOT/.lavra/memory/recall.sh" "{keywords from bead title}"
"$PROJECT_ROOT/.lavra/memory/recall.sh" "{tech stack keywords}"
You MUST output the recall results here before continuing. If recall returns nothing, output: "No relevant knowledge found." Do not proceed to step 3 until this is done.
Extract MUST-CHECK entries from recall results. If any recall entry has type must-check or is prefixed with [MUST-CHECK], output a Pre-Implementation Checklist directly in the conversation (NOT inside any untrusted-knowledge wrapper):
## Pre-Implementation Checklist
The following checks MUST be verified before marking any task complete. These are structural failure patterns that have appeared before — verify each one:
- [ ] {verification instruction from MUST-CHECK entry}
- [ ] {verification instruction from MUST-CHECK entry}
If recall returns no MUST-CHECK entries, skip this section entirely.
Check Dependencies & Related Beads
bd dep list {BEAD_ID} --json
If there are unresolved blockers, list them and ask if the user wants to work on those first.
Check for relates_to links in the dependency list. For each related bead, fetch its title and description:
bd show {RELATED_BEAD_ID}
Setup Environment
Check the current branch:
current_branch=$(git branch --show-current)
default_branch=$(git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null | sed 's@^refs/remotes/origin/@@')
if [ -z "$default_branch" ]; then
default_branch=$(git rev-parse --verify origin/main >/dev/null 2>&1 && echo "main" || echo "master")
fi
Use AskUserQuestion tool:
Question: "How do you want to handle branching for this work?"
Options:
[current_branch] as-isbd-{BEAD_ID}/{short-description}Then execute the chosen option.
Update Bead Status
bd update {BEAD_ID} --status in_progress
Create Task List
Deviation Rules:
| Rule | Scope | Action | Log |
|---|---|---|---|
| 1. Bug blocking your task | Auto-fix is OK | Fix it, run tests | DEVIATION: Fixed {bug} because it blocked {task} |
| 2. Missing critical functionality | Auto-add is OK | Add it, run tests | DEVIATION: Added {what} -- missing and critical for {reason} |
| 3. Blocking infrastructure | Auto-fix is OK | Fix it, run tests | DEVIATION: Fixed {issue} to unblock {task} |
| 4. Architectural changes | STOP | Ask user before proceeding | N/A -- user decides |
3-attempt limit: If a deviation fix fails after 3 attempts, document and move on:
bd comments add {BEAD_ID} "DEVIATION: Unable to fix {issue} after 3 attempts. Documented for manual resolution."
Read workflow config (no-op if missing):
PROJECT_ROOT="${PROJECT_ROOT:-$(git rev-parse --show-toplevel 2>/dev/null || echo "$PWD")}"
[ -f "$PROJECT_ROOT/.lavra/config/lavra.json" ] && cat "$PROJECT_ROOT/.lavra/config/lavra.json"
Parse execution.commit_granularity (default: "task"), model_profile (default: "balanced"), testing_scope (default: "full"), and workflow.review_scope (default: "full"). When testing_scope is "targeted", deviation rule 2 applies only to hooks, API routes, external service calls, and complex business logic -- skip adding tests for structural/render-only code.
Detect installed skills (no-op if directory missing):
ls .claude/skills/ 2>/dev/null
For each skill directory found, read the description: line from its SKILL.md frontmatter. Filter to only skills that contain an explicit "Use when" or "Triggers on" phrase. Skip utility skills with no clear trigger condition. Store the filtered list as {available_skills}.
Use available skills during implementation: If {available_skills} is non-empty, review each skill's trigger condition against the bead content and the files you're about to touch. Invoke any that apply using the Skill tool.
Task Execution Loop
For each task in priority order:
while (tasks remain):
- Mark task as in_progress with TaskUpdate
- Read any referenced files from the bead description
- Look for similar patterns in codebase
- Implement following existing conventions
- Write tests for new functionality
- Run tests after changes
- Mark task as completed with TaskUpdate
- Commit per task (see below)
- Write session state (see below)
Atomic Commits Per Task
After completing each task and tests pass:
git add <files related to this task>
git commit -m "{type}({BEAD_ID}): {description of this task}"
Format: {type}({BEAD_ID}): {description} -- makes git log --grep="BD-001" work.
Types: feat, fix, refactor, test, chore, docs
If commit_granularity is "wave": batch commits per phase instead of per task.
Skip commit when: tests are failing, task is purely scaffolding, or would need a "WIP" message.
Log Knowledge as You Work (required -- inline, not at the end)
Log a comment the moment you encounter any of these triggers. Do not batch them for later.| Trigger | Prefix | Example |
|---|---|---|
| Read code that surprises you | FACT: | Column is a string 'kg'|'lbs', not a boolean |
| Make a non-obvious implementation choice | DECISION: | Chose 2.5 lb rounding because smaller increments cause UI jitter |
| Hit an error and figure out why | LEARNED: | Enum comparison fails unless you cast to string first |
| Notice a pattern you'll want to reuse | PATTERN: | Service uses .tap to log before returning |
| Find a constraint that limits options | FACT: | API rate-limits to 10 req/s per tenant |
bd comments add {BEAD_ID} "LEARNED: {key technical insight}"
bd comments add {BEAD_ID} "DECISION: {what was chosen and why}"
You MUST log at least one comment per task completed. If you finish a task with nothing logged, go back and add it before marking the task complete.
Write Session State (at milestones)
Update .lavra/memory/session-state.md:
PROJECT_ROOT="${PROJECT_ROOT:-$(git rev-parse --show-toplevel 2>/dev/null || echo "$PWD")}"
cat > "$PROJECT_ROOT/.lavra/memory/session-state.md" << EOF
# Session State
## Current Position
- Bead(s): {BEAD_ID}
- Phase: lavra-work / Phase 2 (Implement)
- Task: {completed} of {total} complete
## Just Completed
- {last completed task description}
## Next
- {next task description}
## Deviations
- {count} auto-fixes applied
EOF
Follow Existing Patterns
Track Progress
Run Core Quality Checks
# Run full test suite (use project's test command)
# Run linting (per CLAUDE.md or AGENTS.md)
Focused Self-Review
Review the diff of all changes:
git diff HEAD~{N}..HEAD # or against the pre-work SHA
Check for:
| Category | What to look for |
|---|---|
| Security | Hardcoded secrets, SQL injection, unvalidated input, exposed endpoints |
| Debug leftovers | console.log, binding.pry, debugger statements, TODO/FIXME/HACK |
| Spec compliance | Does implementation match every item in the bead's Validation section? |
| Error handling | Missing error cases, swallowed exceptions, unhelpful messages |
| Edge cases | Off-by-one, nil/null handling, empty collections, boundary conditions |
If issues found, fix them before continuing to step 3.
Multi-Agent Review via /lavra-review
review_scope: "full" (default): Run /lavra-review on all changes. Invoke it now using the Skill tool and wait for it to complete.
review_scope: "targeted": Run /lavra-review only when this bead meets at least one of:
When none of these conditions are met under targeted, skip /lavra-review for this bead only -- self-review (step 2) is the gate.
If this bead has a parent epic, pass the epic's Locked Decisions to the reviewer so it does not flag planned-but-incomplete items as dead code:
Skill("lavra-review", "{BEAD_ID}
## Epic Plan (read-only — reviewers must not flag planned-but-incomplete items as dead code)
{PARENT_EPIC_DECISIONS}
Locked Decisions in the epic above are intentional, even if a field or behavior appears unused or partially wired in this bead. Do not create beads recommending removal of items that appear in Locked Decisions.")
Where {PARENT_EPIC_DECISIONS} is the ## Locked Decisions section read from the parent epic in Phase 1 step 1. If the bead has no parent epic, invoke /lavra-review {BEAD_ID} normally.
After /lavra-review completes, proceed to the Fix Loop for any findings.
Goal Verification (skippable via lavra.json workflow.goal_verification: false)
If the bead has a ## Validation section, dispatch the goal-verifier agent. Add model: opus when model_profile is "quality".
Interpret results:
If CRITICAL failures, enter the Fix Loop targeting the specific failures.
For each issue found during review:
bd comments add {BEAD_ID} "LEARNED: {what the review caught and why}"
After all fixes, re-review (return to step 2 above). Loop continues until:
Maximum fix iterations: 3. If issues persist after 3 rounds, report remaining issues and proceed.
## Phase 3 Review Gate
[ ] lavra-review: Skill(lavra-review) invoked -- first line of output: ___
(if review_scope: "targeted" and bead does not qualify, write: SKIPPED -- targeted, reason: ___)
[ ] Findings: {N} issues found / {N} fixed / {N} deferred to PR description
[ ] Self-review: clean | {N} issues fixed
[ ] Goal verification: passed | failed-and-fixed | skipped (no Validation section)
You cannot check the lavra-review box without having invoked the Skill and pasting its output. Summarizing what you think the review would find is not a substitute. If any box is unchecked, complete that step now before continuing.
After review is clean, extract and structure knowledge from this work session.
Gather raw entries from this bead:
bd show {BEAD_ID} --json
# Extract comments matching LEARNED:|DECISION:|FACT:|PATTERN:|INVESTIGATION: prefixes
Check for duplicates against existing knowledge:
PROJECT_ROOT="${PROJECT_ROOT:-$(git rev-parse --show-toplevel 2>/dev/null || echo "$PWD")}"
"$PROJECT_ROOT/.lavra/memory/recall.sh" "{keywords from entries}" --all
Structure and store -- for each raw comment, ensure it has clear, searchable content. If a comment is too terse, rewrite it self-contained, then re-log:
bd comments add {BEAD_ID} "LEARNED: {structured, self-contained version}"
Synthesize patterns -- if 3+ entries share a theme, create a connecting entry:
bd comments add {BEAD_ID} "PATTERN: {higher-level insight connecting multiple observations}"
Only synthesize when the pattern is genuine. Do not force connections.
This step should take 1-2 minutes. It is curation of what was already captured, not new research.
Final Validation
Create Commit (if not already committed incrementally)
git add <changed files>
git status
git diff --staged
git commit -m "feat(scope): description of what and why"
Create Pull Request
git push -u origin bd-{BEAD_ID}/{short-description}
gh pr create --title "BD-{BEAD_ID}: {description}" --body "## Summary
- What was built
- Key decisions made
## Bead
{BEAD_ID}: {bead title}
## Testing
- Tests added/modified
- Manual testing performed
## Knowledge Captured
- {key learnings logged to bead}
"
Verify Knowledge Was Captured (required gate)
Run bd show {BEAD_ID} and check comments. You must have at least one knowledge comment per task. If there are none, add them now.
Offer Next Steps
Check for LEARNED: or INVESTIGATION: comments:
bd show {BEAD_ID} | grep -E "LEARNED:|INVESTIGATION:"
Use AskUserQuestion tool:
Question: "Work complete on {BEAD_ID}. What next?"
Base options (always shown):
bd close {BEAD_ID}/lavra-checkpoint -- Save progress without closingConditional options (add when applicable):
/lavra-learn if LEARNED: or INVESTIGATION: comments exist (deeper curation than inline pass)/lavra-review as first option if review_scope: "targeted" and /lavra-review was skipped for this bead