- Home
- Skills
- Agents & Orchestration
- SpecOpsPipeline: Lead-Worker Code Audit & Refactor
SpecOpsPipeline: Lead-Worker Code Audit & Refactor
Orchestrate subagents to audit codebases and perform scoped refactors in isolated git worktrees.
Free
Works with the AI Agents you already use
SpecOpsPipeline: Lead-Worker Code Audit & Refactor
Example session with this skill installed
Audit the current project for outdated error handling patterns and refactor them using the Lead-Worker workflow.
- Read your context and instructions
- Compiled the specopspipeline
I have completed the preflight and audit of the codebase. I found 8 instances of legacy error handling patterns that should be migrated to the new Result type.
Audit & Execution Plan
| Task ID | Severity | Scope | Worker Tier | Dependency |
|---|---|---|---|---|
err-01 | High | src/auth/* | Standard | None |
err-02 | High | src/api/v1/* | Standard | None |
err-03 | Medium | src/utils/parsers.ts | Light | None |
Gap Report Findings
Finding [err-01]: src/auth/service.ts:42 - Uses throw-catch for flow control. Evidence: throw new AuthError(). Fix: Return Err(AuthError).
2. Finding [err-02]: src/api/v1/router.ts:15 - Missing error propagation. Fix: Wrap response in Result wrapper.
3.
Finding [err-03]: src/utils/parsers.ts:89 - Native Error used instead of domain errors. Fix: Map to ParserError.
Execution Plan
- Mode:
independent - Session:
split(Recommended due to task count) - Parallelism: 3 workers
- PR Mode: Open and Auto-merge on APPROVE
Next steps
- Review the generated specs in
.git/so-run/spec-*.md. - Approve the plan to dispatch workers to their respective worktrees.
- Switch to the
lead_phase2model once I provide the resume command.
Connects securely to your tools. The creator never sees your data.
About this skill
Scale code audits and large-scale refactors without losing control or cluttering your context. This skill implements a Lead-Worker orchestration pattern that delegates specific, scoped tasks to subagents while you maintain the role of high-level architect and reviewer.
What it does
- Lead-Worker orchestration manages subagents to execute refactors in isolated git worktrees.
- Automated gap analysis scans codebases read-only to produce structured findings and fix proposals.
- Isolated execution enforces whitelists so subagents cannot touch files outside their assigned scope.
- Dependency-aware scheduling runs independent tasks in parallel and related tasks in ordered stages.
- Rigid verification gates every subagent contribution through Definition of Done (DoD) checks and diff reviews.
How it works
- Preflight and Audit: The Lead scans the repository to identify issues and groups them into specific tasks.
- Spec and Plan: You approve an execution plan where each task has a dedicated spec, whitelist, and DoD criteria.
- Dispatch: Subagents are launched into separate worktrees to implement the fixes simultaneously.
- Gate and Review: The Lead validates each worktree against the whitelist and re-runs tests before approving the PR.
Frameworks & tools
Uses standard git worktree features, bash scripts for lifecycle management, and GitHub CLI for PR orchestration.
Why this beats prompting it yourself
Manual prompting for large refactors often leads to context drift, hallucinated file paths, and accidental regressions. This skill provides a structured state machine that isolates subagents, strictly enforces file boundaries, and automates the tedious verification of multi-file changes.
Use cases
- Legacy cleanup to remove technical debt across large directory structures in parallel.
- Security patching by sweeping for vulnerabilities and delegating specific fixes to workers.
- API migrations where repetitive changes across many files need strict verification.
Known limitations
Requires a functional git environment and existing test suites for DoD verification. Parallel worker limits are dictated by the host machine's resources and API rate limits.
Requires git worktree support. Relies on existing repo test suites for DoD verification. Parallel worker execution is subject to model rate limits.
How to use
- 1
Connect your agent to the Agensi MCP
Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup
- 2
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 3
Ask for what you need
Your agent loads this skill and uses it on your task. It always asks before any payment.
Reviews
This skill has been used 4 times.
Trust & safety
Security scan
Security scan passed 3 days ago
- Free with an Agensi account
Requires