From agentops
Implements one tracked issue end-to-end: focused code edits, tests, commit, closure evidence. Uses bd CLI for tracking, ao for knowledge lookup and gates.
npx claudepluginhub boshu2/agentops --plugin agentopsThis skill uses the workspace's default tool permissions.
> **Quick Ref:** Execute single issue end-to-end. Output: code changes + commit + closed issue.
Creates isolated Git worktrees for feature branches with prioritized directory selection, gitignore safety checks, auto project setup for Node/Python/Rust/Go, and baseline verification.
Executes implementation plans in current session by dispatching fresh subagents per independent task, with two-stage reviews: spec compliance then code quality.
Dispatches parallel agents to independently tackle 2+ tasks like separate test failures or subsystems without shared state or dependencies.
Quick Ref: Execute single issue end-to-end. Output: code changes + commit + closed issue.
YOU MUST EXECUTE THIS WORKFLOW. Do not just describe it.
Execute a single issue from start to finish.
CLI dependencies: bd (issue tracking), ao (ratchet gates). Both optional — see skills/shared/SKILL.md for fallback table. If bd is unavailable, use the issue description directly and track progress via TaskList instead of beads.
Given /implement <issue-id-or-description>:
For resume protocol details, read skills/implement/references/resume-protocol.md.
For ratchet gate checks and pre-mortem gate details, read skills/implement/references/gate-checks.md.
# Pull knowledge scoped to this issue (if ao available)
ao lookup --bead <issue-id> --limit 3 2>/dev/null || true
Apply retrieved knowledge (mandatory when results returned):
If learnings or patterns are returned, do NOT just load them as passive context. For each returned item:
After reviewing, record each citation with the correct type:
# Only use "applied" when the learning actually influenced your output.
# Use "retrieved" for items that were loaded but not referenced in your work.
ao metrics cite "<learning-path>" --type applied 2>/dev/null || true # influenced a decision
ao metrics cite "<learning-path>" --type retrieved 2>/dev/null || true # loaded but not used
Section evidence: When lookup results include section_heading, matched_snippet, or match_confidence fields, prefer the matched section over the whole file — it pinpoints the relevant portion. Higher match_confidence (>0.7) means the section is a strong match; lower values (<0.4) are weaker signals. Use the matched_snippet as the primary context rather than reading the full file.
Skip silently if ao is unavailable or returns no results.
If beads issue ID provided (e.g., gt-123):
bd show <issue-id> 2>/dev/null
If plain description provided: Use that as the task description.
If no argument: Check for ready work:
bd ready 2>/dev/null | head -3
bd update <issue-id> --status in_progress 2>/dev/null
if command -v ao &>/dev/null; then
ao context assemble --task='<issue title and description>'
fi
This produces a 5-section briefing (GOALS, HISTORY, INTEL, TASK, PROTOCOL) at .agents/rpi/briefing-current.md with secrets redacted. Read it before gathering additional context.
Before exploring or editing, load the behavioral discipline standard from /standards and write a short execution frame for yourself:
Assumptions: what is known, what is ambiguous, and which unknowns would change the solutionSmallest change: the minimum patch that could satisfy the requestBlast radius: which files or surfaces are in scope, plus what is explicitly out of scopeVerification: the tests, commands, or gates that will prove the work is doneRules:
USE THE TASK TOOL to explore relevant code:
Tool: Task
Parameters:
subagent_type: "Explore"
description: "Gather context for: <issue title>"
prompt: |
Find code relevant to: <issue description>
1. Search for related files (Glob)
2. Search for relevant keywords (Grep)
3. Read key files to understand current implementation
4. Identify where changes need to be made
Return:
- Files to modify (paths)
- Current implementation summary
- Suggested approach
- Any risks or concerns
Before implementing any new function or utility, grep the codebase for existing implementations:
# Search for the function name pattern you're about to create
grep -rn "<function-name-pattern>" --include="*.go" --include="*.py" --include="*.ts" .
Why: In context-orchestration-leverage, a worker created a duplicate estimateTokens function that already existed in context.go. A 5-second grep would have prevented the duplication and the rework needed to consolidate it.
If you find an existing implementation, reuse it. If it needs modification, modify it in place rather than creating a parallel version.
Before implementing, write tests that define the expected behavior:
# Run tests - ALL new tests must FAIL
# Python: pytest tests/test_<feature>.py -v
# Go: go test ./path/to/... -run TestNew
# Node: npm test -- --grep "new feature"
Test level selection: Classify each test by pyramid level (see the test pyramid standard (test-pyramid.md in the standards skill)):
If the issue includes test_levels metadata from /plan, use those levels. Otherwise, default to L1 + any applicable higher levels from the decision tree above.
When delegating to /test, carry those selected levels and any BF expectations into the request context. --quick is not permission to collapse to L1-only coverage.
Bug-Finding Level Selection (alongside L0–L3):
If the implementation touches external boundaries (APIs, databases, file I/O):
If the implementation includes data transformations (parse, render, serialize):
If the implementation generates output files (configs, reports, manifests):
Reference: the test pyramid standard in /standards for full tooling matrix.
RED Verification Gate (mechanical): After writing tests, run the test suite and verify ALL new tests FAIL:
--no-tdd flag is set, GREEN mode is active, or issue type is chore, docs, or ciSkip conditions (any of these bypasses Step 3.5):
/crank --test-first — tests already exist)chore, docs, or ci--no-tdd flag is setNote: Tests written here are MUTABLE — unlike GREEN mode's immutable tests, you may adjust these tests during implementation if you discover the initial test design was wrong. The goal is to think about behavior before code, not to be rigid.
If skip conditions above are NOT met AND --no-lifecycle is NOT set:
Skill(skill="test", args="generate <feature-scope> --quick")
The generated test request must preserve the selected test_levels and BF expectations from Step 3.6. Review the generated tests. Adjust as needed (tests are MUTABLE in this context). If /test fails to produce useful output or is unavailable, fall back to manual test writing in Step 3.6 above.
Skip if: --no-lifecycle flag, GREEN mode active, issue type is chore/docs/ci, or /test is unavailable.
CI-safe tests: If the function under test shells out to an external CLI (bd, ao, gh), do NOT test the wrapper. Instead, test the underlying function that performs the testable work (event emission, state mutation, file I/O). See the Go standards (Testing section) for examples.
GREEN Mode check: If test files were provided (invoked by /crank --test-first):
Based on the context gathered:
If the project has a Go cmd/ directory or a Makefile with a build target, run build verification before proceeding to tests:
# Detect CLI repo
if [ -f go.mod ] && ls cmd/*/main.go &>/dev/null; then
echo "CLI repo detected — running build verification..."
# Build
go build ./cmd/... 2>&1
if [ $? -ne 0 ]; then
echo "BUILD FAILED — fix compilation errors before proceeding"
# Do NOT proceed to Step 5
fi
# Vet
go vet ./cmd/... 2>&1
# Smoke test: run the binary with --help
BINARY=$(ls -t cmd/*/main.go | head -1 | xargs dirname | xargs basename)
if [ -f "bin/$BINARY" ]; then
./bin/$BINARY --help > /dev/null 2>&1
echo "Smoke test: $BINARY --help passed"
fi
fi
If build fails: Fix compilation errors and re-run before proceeding. Do NOT skip to verification with a broken build.
If not a CLI repo: This step is a no-op — proceed directly to Step 5.
Before proceeding to functional verification, check for common security issues in modified code:
| Check | What to Look For | Action |
|---|---|---|
| Input validation | User/external input used without validation | Add validation at entry points |
| Output escaping | Raw data in HTML/templates (innerHTML, document.write, dangerouslySetInnerHTML) | Use framework auto-escaping or explicit sanitization |
| Path safety | Path traversal via .. sequences; file paths from user input without sanitization | Reject .., absolute paths; use filepath.Clean() or equivalent; verify path stays within allowed directory |
| Auth gates | Endpoints/handlers missing authentication or authorization checks | Add middleware or guard clauses |
| Content-Type | HTTP responses without explicit Content-Type headers | Set Content-Type to prevent MIME-sniffing attacks |
| CORS | Overly permissive CORS configuration (* origin, credentials: true) | Restrict to known origins; never combine wildcard with credentials |
| CSRF tokens | State-changing endpoints (POST/PUT/DELETE) without anti-CSRF tokens | Add anti-CSRF token validation; do not rely solely on cookies for auth |
| Rate limiting | Authentication, API, and upload endpoints without rate limits | Add rate-limit middleware; return 429 with Retry-After header |
Skip when: The change does not involve HTTP handlers, user-facing input, file system operations, or template rendering. Pure internal refactors, test-only changes, and documentation edits skip this step.
If issues found: Fix before proceeding to Step 5. Log fixes in the commit message.
Success Criteria (all must pass):
Check for test files and run them:
# Find tests
ls *test* tests/ test/ __tests__/ 2>/dev/null | head -5
# Run tests (adapt to project type)
# Python: pytest
# Go: go test ./...
# Node: npm test
# Rust: cargo test
If tests exist: All tests must pass. Any failure = verification failed.
If no tests exist: Manual verification required:
If verification fails: Do NOT proceed to Step 5a. Fix the issue first.
THE IRON LAW: NO COMPLETION CLAIMS WITHOUT FRESH VERIFICATION EVIDENCE
Before reporting success, you MUST:
Forbidden phrases without fresh verification evidence:
| Excuse | Reality |
|---|---|
| "Too simple to verify" | Simple code breaks. Verification takes 10 seconds. |
| "I just ran it" | Run it AGAIN. Fresh output only. |
| "Tests passed earlier" | Run them NOW. State changes. |
| "It's obvious it works" | Nothing is obvious. Evidence or silence. |
| "The edit looks correct" | Looking != working. Run the code. |
Store checkpoint:
bd update <issue-id> --append-notes "CHECKPOINT: Step 5a verification passed at $(date -Iseconds)" 2>/dev/null
When invoked by /crank with --test-first, the worker receives:
GREEN Mode Rules:
MODIFIED_TESTS=$(git diff --name-only -- '*_test.go' '*_test.py' '*.test.ts' '*.test.js' '*.spec.ts' '*.spec.js')
if [ -n "$MODIFIED_TESTS" ]; then
echo "BLOCK: GREEN mode violation: test file modified: $MODIFIED_TESTS"
# Revert test changes and re-implement without modifying tests
fi
Opt-out: --allow-test-modification flag (for cases where test fixtures need updating)Verification (GREEN Mode):
Test Immutability Enforcement:
Before committing, run a fix-verify loop on all files modified in this session (max 3 iterations):
Iteration N:
git diff --name-only HEAD_ = err or empty catch blocks)--no-lifecycle is NOT set AND lifecycle tier is standard or full AND staged changes exist:
Skill(skill="review", args="--diff --staged --quick")
Merge review findings into the defect list. CRITICAL → HIGH, WARNING → MEDIUM, NIT → LOW.
This runs EXACTLY ONCE (first iteration only) — do NOT re-run review after fixes.
Skip if: --no-lifecycle flag, lifecycle tier is minimal or fast, no staged changes.4a. Complexity-triggered refactor check (once per loop, first iteration only):
If --no-lifecycle is NOT set AND lifecycle tier is full AND any modified function has cyclomatic complexity > 15:
Skill(skill="refactor", args="<high-cc-function> --dry-run")
Treat refactor suggestions as MEDIUM findings. Do NOT auto-apply — report only.
Skip if: --no-lifecycle flag, lifecycle tier is not full, no function exceeds CC > 15.
Loop termination:
--force-commit allows proceeding with documented HIGHs (explicit opt-in only)Output: Record iteration count, findings per iteration, and remaining items.
If no modified files or sweep finds zero issues on first pass, proceed directly to Step 5c.
Skip if: --no-spec flag, or issue type is docs/chore/ci.
After verification passes, produce a behavioral spec documenting what the implementation does. This feeds Stage 4 behavioral validation (STEP 1.8 in /validation).
mkdir -p .agents/specs
cat > .agents/specs/<issue-id>.json <<'SPEC'
{
"id": "auto-<issue-id>",
"version": 1,
"date": "<YYYY-MM-DD>",
"goal": "<one-line: what user outcome this implementation serves>",
"narrative": "<2-3 sentences: what the implementation does and how a user interacts with it>",
"expected_outcome": "<what a satisfied user observes when this works correctly>",
"acceptance_vectors": [
{
"dimension": "<name: correctness|performance|usability|security|...>",
"threshold": <0.0-1.0>,
"check": "<optional: mechanical check command>"
}
],
"satisfaction_threshold": 0.7,
"scope": {
"files": ["<list of modified files>"],
"functions": ["<key functions added/modified>"],
"behaviors": ["<behavioral descriptions>"]
},
"source": "agent",
"status": "active"
}
SPEC
Guidelines:
acceptance_vectors should capture the BEHAVIORAL contract, not test assertions.
Example: {"dimension": "isolation", "threshold": 1.0, "check": "echo ... | bash hook; test $? -eq 2"}scope.files must match the files you actually modified (not planned files).If skipped: Log "Behavioral spec skipped (reason: <flag|issue-type>)" and proceed.
If the change is complete and verified:
git add <modified-files>
git commit -m "<descriptive message>
Implements: <issue-id>"
bd update <issue-id> --status closed 2>/dev/null
After successful issue closure, record in ratchet:
# Check if ao CLI is available
if command -v ao &>/dev/null; then
# Get the commit hash as output artifact
COMMIT_HASH=$(git rev-parse HEAD 2>/dev/null || echo "")
CHANGED_FILES=$(git diff --name-only HEAD~1 2>/dev/null | tr '\n' ',' | sed 's/,$//')
if [ -n "$COMMIT_HASH" ]; then
# Record successful implementation
# Determine TDD mode for ratchet tracking
# Values: red (wrote failing tests), green (GREEN mode from crank),
# skipped (skip conditions met), no-tdd (explicitly disabled)
TDD_MODE="red" # default when TDD was followed
# Override based on context:
# GREEN mode → "green", skip conditions → "skipped", --no-tdd → "no-tdd"
ao ratchet record implement \
--tdd-mode "$TDD_MODE" \
--output "$COMMIT_HASH" \
--files "$CHANGED_FILES" \
--issue "<issue-id>" \
2>&1 | tee -a .agents/ratchet.log
if [ $? -eq 0 ]; then
echo "Ratchet: Implementation recorded (commit: ${COMMIT_HASH:0:8})"
else
echo "Ratchet: Failed to record - chain.jsonl may need repair"
fi
else
echo "Ratchet: No commit found - skipping record"
fi
else
echo "Ratchet: ao CLI not available - implementation NOT recorded"
echo " Run manually: ao ratchet record implement --output <commit>"
fi
On failure/blocker: Record the blocker in ratchet:
if command -v ao &>/dev/null; then
ao ratchet record implement \
--status blocked \
--reason "<blocker description>" \
2>/dev/null
fi
Fallback: If ao is not available, the issue is still closed via bd but won't be tracked in the ratchet chain. The skill continues normally.
After implementation is complete:
if command -v ao &>/dev/null; then
ao ratchet record implement --output "<issue-id>" 2>/dev/null || true
fi
Tell user: "Implementation complete. Run /validation to validate before pushing."
Tell the user:
Output completion marker:
<promise>DONE</promise>
If blocked or incomplete:
<promise>BLOCKED</promise>
Reason: <why blocked>
<promise>PARTIAL</promise>
Remaining: <what's left>
| Flag | Default | Description |
|---|---|---|
--no-lifecycle | off | Skip ALL lifecycle skill auto-invocations (test gen, review, refactor) |
--lifecycle=<tier> | matches complexity | Controls which lifecycle skills fire: minimal (test only), standard (+review), full (+refactor dry-run) |
Lifecycle tier defaults to matching the current complexity level. Explicit --lifecycle=<tier> overrides.
--no-tdd)--no-lifecycle)If bd CLI not available:
User says: /implement ag-5k2
What happens:
middleware/auth.go to add token validationgo test ./middleware/... — all tests passbd update ag-5k2 --status closedResult: Issue implemented, verified, committed, and closed. Ratchet recorded.
User says: /implement
What happens:
bd ready — finds ag-3b7 (first unblocked issue)bd update ag-3b7 --status in_progressResult: Autonomous work pickup and completion from ready queue.
User says: /implement ag-8h3 (invoked by /crank --test-first)
What happens:
Result: Minimal implementation driven by tests, no over-engineering.
| Problem | Cause | Solution |
|---|---|---|
| Issue not found | Issue ID doesn't exist or local state looks stale | Run bd show <id> to verify; use bd vc status only if you need Dolt state |
| GREEN mode violation | Edited a file not related to the issue scope | Revert unrelated changes. GREEN mode restricts edits to files relevant to the issue |
| Verification gate fails | Tests fail or build breaks after implementation | Read the verification output, fix the specific failures, re-run verification |
| "BLOCKED" status | Contract contradicts tests or is incomplete in GREEN mode | Write BLOCKED with specific reason, do NOT modify tests |
| Fresh verification missing | Agent claims success without running verification command | MUST run verification command fresh with full output before claiming completion |
| Ratchet record failed | ao CLI unavailable or chain.jsonl corrupted | Implementation still closes via bd, but ratchet chain needs manual repair |