npx skills add ...
npx skills add getsentry/xcodebuildmcp --skill warden-sweep
npx skills add getsentry/xcodebuildmcp --skill warden-sweep
Full-repository code sweep. Scans every file with warden, verifies findings via deep tracing, creates draft PRs for validated issues. Use when asked to "sweep the repo", "scan everything", "find all bugs", "full codebase review", "batch code analysis", or run warden across the entire repository.
Full-repository code sweep: scan every file, verify findings with deep tracing, create draft PRs for validated issues.
Requires: warden, gh, git, jq, uv
Important: Run all scripts from the repository root using ${CLAUDE_SKILL_ROOT}. Output goes to .warden/sweeps/<run-id>/.
scripts/scan.pyRuns setup and scan in one call: generates run ID, creates sweep dir, checks deps, creates warden label, enumerates files, runs warden per file, extracts findings.
scripts/index_prs.pyFetches open warden-labeled PRs, builds file-to-PR dedup index, caches diffs for overlapping PRs.
scripts/create_issue.pyCreates a GitHub tracking issue summarizing sweep results. Run after verification, before patching.
scripts/organize.pyTags security findings, labels security PRs, updates finding reports with PR links, posts final results to tracking issue, generates summary report, finalizes manifest.
scripts/extract_findings.pyParses warden JSONL log files and extracts normalized findings. Called automatically by scan.py.
scripts/generate_report.pyBuilds summary.md and report.json from sweep data. Called automatically by organize.py.
scripts/find_reviewers.pyFinds top 2 git contributors for a file (last 12 months).
Returns JSON: {"reviewers": ["user1", "user2"]}
Run (1 tool call):
To resume a partial scan:
Parse the JSON stdout. Save runId and sweepDir for subsequent phases.
Report to user:
Render every finding from the findings array. Bold severity for high and above.
On failure: If exit code 1, show the error JSON and stop. If exit code 2, show the partial results. List timed-out files separately from errored files so users know which can be retried.
Deep-trace each finding using Task subagents to qualify or disqualify.
For each finding in data/all-findings.jsonl:
Check if data/verify/<finding-id>.json already exists (incrementality). If it does, skip.
Launch a Task subagent (subagent_type: "general-purpose") for each finding. Process findings in parallel batches of up to 8 to improve throughput.
Task prompt for each finding:
Read ${CLAUDE_SKILL_ROOT}/references/verify-prompt.md for the prompt template. Substitute the finding's values into the ${...} placeholders.
Process results:
Parse the JSON from the subagent response and:
data/verify/<finding-id>.jsondata/verified.jsonl or data/rejected.jsonlfindings/<finding-id>.md:{verified} verified, {rejected} rejected.
| # | Severity | Confidence | File | Title | Reasoning |
|---|---|---|---|---|---|
| 1 | HIGH | high | src/db/query.ts:42 | SQL injection in query builder | User input flows directly into... |
| ... |
{findingId} {file}: {reasoning}
...Parse the JSON stdout. Save issueUrl and issueNumber for Phase 4.
Report to user:
On failure: Show the error. Continue to Phase 4 (PRs can still be created without a tracking issue).
For each verified finding, create a worktree, fix the code, and open a draft PR. Process findings sequentially (one at a time) since parallel subagents cross-contaminate worktrees.
Severity triage: Patch HIGH and above. For MEDIUM, only patch findings from bug-detection skills (e.g., code-review, security-review). Skip LOW and INFO findings.
Step 0: Setup (run once before the loop):
Parse the JSON stdout. Use fileIndex for dedup checks.
Determine the default branch and fetch latest so worktrees branch from current upstream:
For each finding in data/verified.jsonl:
Check if finding ID already exists in data/patches.jsonl (incrementality). If it does, skip.
Dedup check: Use the file index from index_prs.py output to determine if an existing open PR already addresses the same issue.
fileIndex. If no PR touches that file, no conflict; proceed to Step 1.data/pr-diffs/<number>.diff and check whether the PR's changed hunks overlap with the finding's line range (startLine-endLine). Overlapping or adjacent hunks (within ~10 lines) indicate the same code region.Skip the finding only when there is both chunk overlap AND the PR addresses the same concern. Record it in data/patches.jsonl with "status": "existing" and "prUrl" pointing to the matching PR, then continue to the next finding.
Step 1: Create worktree
Each finding branches from the repo's default branch so PRs contain only the fix commit.
Step 2: Generate fix
Launch a Task subagent (subagent_type: "general-purpose") to apply the fix in the worktree. Read ${CLAUDE_SKILL_ROOT}/references/patch-prompt.md for the prompt template. Substitute the finding's values and worktree path into the ${...} placeholders.
Step 2b: Handle skipped findings
If the subagent returned "status": "skipped" (not "applied"), do NOT proceed to Steps 3-4. Instead:
data/patches.jsonl with "status": "error" and "error": "Subagent skipped: ${skipReason}"Step 3: Find reviewers
Step 4: Create draft PR
Create the PR with a 1-2 sentence "What" summary based on the finding and fix, followed by the finding description and verification reasoning:
Save the PR URL.
Step 5: Record and cleanup
Append to data/patches.jsonl (use "created" as status for successful PRs, not the subagent's "applied"):
Remove the worktree:
Error handling: On failure at any step, write to data/patches.jsonl with "status": "error" and "error": "...", clean up the worktree, and continue to the next finding.
Update manifest: set phases.patch to "complete".
Report to user after all patches:
Run (1 tool call):
Parse the JSON stdout.
Report to user:
On failure: Show the error and note which steps completed.
Each phase is incremental. To resume from where you left off:
data/manifest.json to see which phases are complete--sweep-dir to scan.pydata/verify/<id>.json files are skippedcreate_issue.py is idempotent (skips if issueUrl in manifest)data/patches.jsonl are skippeduv run ${CLAUDE_SKILL_ROOT}/scripts/organize.py <sweep-dir>uv run ${CLAUDE_SKILL_ROOT}/scripts/extract_findings.py <log-path-or-directory> -o <output.jsonl>uv run ${CLAUDE_SKILL_ROOT}/scripts/generate_report.py <sweep-dir>uv run ${CLAUDE_SKILL_ROOT}/scripts/find_reviewers.py <file-path>uv run ${CLAUDE_SKILL_ROOT}/scripts/scan.pyuv run ${CLAUDE_SKILL_ROOT}/scripts/scan.py --sweep-dir .warden/sweeps/<run-id>## Scan Complete
Scanned **{filesScanned}** files, **{filesTimedOut}** timed out, **{filesErrored}** errors.
### Findings ({totalFindings} total)
| # | Severity | Skill | File | Title |
|---|----------|-------|------|-------|
| 1 | **HIGH** | security-review | `src/db/query.ts:42` | SQL injection in query builder |
...