Best for
- Initial broad audit (round 1)
- Security reviews (specialized security-reviewer agent)
- When you need 3+ perspectives (multi-explorer)
baphuongna/pi-crew/skills/iterative-audit/SKILL.md
Iterative multi-round codebase audit with diminishing-returns detection. Run 5-20+ rounds, each focusing on one specific area. Built from 19 rounds of dogfooding pi-crew on itself.
Decision brief
Distilled from 19 rounds of auditing pi-crew on itself (v0.5.5 → v0.5.14): 70 issues fixed, 286 tests added, 9 security improvements, 2 performance improvements.
Compatibility matrix
| Platform | Status | Evidence | What to check |
|---|---|---|---|
| Codex | Not declared | No explicit evidence | Portability before use |
| Claude Code | Not declared | No explicit evidence | Portability before use |
| Cursor | Not declared | No explicit evidence | Portability before use |
| Gemini CLI | Not declared | No explicit evidence | Portability before use |
Installation
The source command is displayed only when detected. A safe inspection prompt is always available so your agent can explain every action before execution.
npx skills add https://github.com/baphuongna/pi-crew --skill "skills/iterative-audit"Inspect the Agent Skill "iterative-audit" from https://github.com/baphuongna/pi-crew/blob/519a5e4e374c1ff6bf02dd05830b11359d1302b1/skills/iterative-audit/SKILL.md at commit 519a5e4e374c1ff6bf02dd05830b11359d1302b1. List every install step, command, network request, credential, file read/write, external action, and rollback step. Explain whether it fits my task. Do not install or execute anything until I approve.
Workflow
Choose ONE of the 7 patterns above. Don't try to do multiple patterns in one round.
Choose ONE of the 7 patterns above. Don't try to do multiple patterns in one round.
Read the actual source for the focus area. Don't trust prior audit docs.
For each candidate issue: - Read the file at the cited line - Check if the issue is real (not a false positive) - Check if it's already fixed - Note the exact file:line and code snippet
Review the “Step 4: Create a plan doc” section in the pinned source before continuing.
Permission review
The documentation asks the agent to read local files, directories, or repositories.
Read the file at the cited lineEvidence record
| Signal | Value | Evidence type | Meaning |
|---|---|---|---|
| Quality score | 92/100 | Computed | Documentation, specificity, maintenance, and trust rules |
| Repository stars | 50 | Source | Repository attention, not individual Skill quality |
| Compatibility | 0 platforms | Source | Declared in the catalog source record |
| Usage guide | automated source guide | Editorial | Generated or reviewed according to the visible evidence level |
Pinned source
Distilled from 19 rounds of auditing pi-crew on itself (v0.5.5 → v0.5.14): ~70 issues fixed, 286 tests added, 9 security improvements, 2 performance improvements.
The core insight: a single round of audit finds the easy 30% of bugs. The remaining 70% only surfaces through 5-20+ targeted rounds, each with a specific focus. After round 5+ you find HIGH severity bugs that round 1 missed. After round 10+ you find issues that no human reviewer would catch in a single pass.
git diff and inspect. ~20% of team runs silently fail to apply changes.After 19 rounds, every issue found falls into one of these 7 categories. Use this to plan each round's focus.
What: Replace console.error / console.warn / process.stderr.write with logInternalError() from utils/internal-error.ts.
Why: console.error may not be visible in JSON-RPC mode or when stderr is redirected. logInternalError is the project-wide pattern; missing it means errors are silently dropped.
How to find them:
rg -n 'console\.(error|warn|log)' src/
rg -n 'process\.stderr\.write' src/
Rule: Skip internal-error.ts:5 itself (it's the implementation). Skip background-runner.ts:146 (overrides console.error for testing). Skip parent-guard.ts:37 (exit-time log must fire synchronously).
Time per round: 30 min for 5-10 callsites. Diminishing returns after round 1.
What: Find Maps, Sets, Arrays, and Queues that grow unboundedly. Add MAX_* constants and eviction logic.
Why: Long-running processes (background runners, extension reloads) accumulate state. Without caps, a busy period causes OOM.
How to find them:
rg -n 'new Map\(' src/ # look for ones that are .set() repeatedly
rg -n 'new Set\(' src/
rg -n 'this\.\w+\.push\(' src/ # look for unbounded arrays
Common patterns:
Semaphore.#queue → add MAX_QUEUE cap (pi-crew: 10,000)liveAgentManager.liveAgents Map → add MAX_LIVE_AGENTS cap (pi-crew: 5,000)OverflowRecoveryTracker.states Map → add MAX_TRACKED_STATES cap (pi-crew: 5,000)NotificationRouter.seen Map → add SEEN_MAP_MAX_SIZE cap (pi-crew: 10,000)Eviction strategies (in order of preference):
lastAccessAt per entryTest pattern: Verify cap by inserting 1.5× the max, confirm old entries are gone.
What: Find source files with zero direct unit tests.
How to find them:
# For each src file, check if any test file imports it
for f in src/runtime/*.ts src/extension/*.ts; do
basename=$(basename "$f" .ts)
count=$(ls test/unit/${basename}*.test.ts 2>/dev/null | wc -l)
[ "$count" = "0" ] && echo "NO TEST: $f"
done
Prioritize:
sandbox.ts, child-pi.ts, pi-spawn.ts, crew-cleanup.tslive-agent-manager.ts, semaphore.ts, overflow-recovery.tsexport class or export functionDon't test: internal helpers, generated code, pure re-exports.
Test categories (in order of importance):
assertSafePathId, path traversal rejectiondispose() clears everything, listeners don't stackresultConsumed flagWhat: Find places where untrusted input reaches dangerous sinks.
Common sinks to audit:
execSync(command) → switch to execFileSync(program, args[])eval() / Function() / vm.runInNewContext() → avoid entirelypath.join(base, userInput) → use assertSafePathId(userInput) firstprocess.env access → use sanitized env with allow-listcwd: knownDir, sanitize envHow to find them:
rg -n 'execSync\(' src/
rg -n 'exec\(' src/
rg -n 'eval\(|Function\(' src/
rg -n 'spawn\(' src/
rg -n 'path\.join\(' src/ | rg 'record\.|task\.|runId|agent\.'
Round 1: Find all execSync and exec. Switch to execFileSync(program, args) (no shell).
Round 2: Audit env handling. Look for process.env access in hot paths. Add allow-list.
Round 3: Path traversal. For every path.join(base, userInput), add assertSafePathId().
Round 4: Subprocess safety. Verify all spawn() calls have: validated args, sanitized env, cwd set, signal handling, timeout.
What: Find O(N²) or worse algorithms, especially in hot paths.
Common patterns:
array.filter().map().filter() in a loop → fuse into one passJSON.parse of the same file repeatedly → cachefs.statSync per file in a directory scan → batch with Dirent.isDirectory()setTimeout busy-polling for state changes → use fs.watch or eventsHow to find them:
# Look for nested loops over the same data
rg -nB 1 -A 5 'for.*of.*for' src/
# Look for polls
rg -n 'setTimeout.*poll' src/
rg -n 'pollIntervalMs' src/
Test pattern: For precomputation fixes, write a perf test that creates 1000 docs, runs search, and asserts completion under 100ms.
What: Remove dead code, fix type misuse, add missing JSDoc.
Common patterns:
seenCleanupCounter)as any, as unknown as T) that hide real issuesHow to find them:
# Find fields/methods declared but never used
rg -n 'private \w+\s*=\s*' src/ | while read line; do
field=$(echo "$line" | grep -oP 'private \K\w+')
count=$(rg -c "\b$field\b" src/ 2>/dev/null | head -1)
[ "$count" = "1" ] && echo "DEAD: $line"
done
What: Find places where listeners, timers, file handles, or other resources can leak.
Common patterns:
process.on('SIGTERM', ...) registered multiple times → use module-level flagsetInterval / setTimeout not cleared on shutdown → dispose() methodAbortController not aborted in cleanupfs.watch) not closedemitter.on) not removedHow to find them:
rg -n 'process\.on\(' src/
rg -n 'setInterval\(' src/
rg -n 'setTimeout\(' src/ | rg -v 'setTimeout.*resolve' # filter out poll sleeps
rg -n 'fs\.watch\(' src/
Test pattern: Call the registration function N times, verify listener count is 1.
Choose ONE of the 7 patterns above. Don't try to do multiple patterns in one round.
Read the actual source for the focus area. Don't trust prior audit docs.
For each candidate issue:
# Round N Audit Fix Plan
## Findings
### Issue 1: <file>:<line> — <title> (severity)
<File path and line numbers>
<Code snippet showing the issue>
<Rationale>
## Plan (5 phases)
### Phase 1: <action>
### Phase 2: <action>
...
npx tsc --noEmitnpm testfix: round N - <summary>After 5-10 rounds, evaluate:
Continue if:
Stop if:
Use teams (via team action='run', team='review') for:
security-reviewer agent)Do it yourself for:
Teams often fail because:
startTeamRunHeartbeat if needed)After 19 rounds, ~30% of audit findings are false positives. Common patterns:
cleanedUp || !currentCtx you missedAlways verify against source before acting. If you're not sure, write a test that exercises the alleged bug path. If the test passes, it's a false positive.
After each round, record:
Healthy round: 3-8 real issues found, +20 to +50 tests added, all pass.
Exhausted round: 0-1 real issues found, 0 tests added, mostly L1 cleanup.
When you hit 2+ exhausted rounds in a row, stop.
| Round | Focus | Issues Found | Severity Range |
|---|---|---|---|
| 1-3 | Broad security audit | 11 | CRITICAL, HIGH |
| 4-6 | Race conditions, locks | 5 | HIGH |
| 7-9 | L1 cleanup, dead code | 12 | LOW |
| 10-12 | Defensive caps | 3 | MEDIUM |
| 13-15 | Security: execSync, sandbox | 9 | CRITICAL, HIGH |
| 16-18 | Test coverage, L1 | 30+ | LOW |
| 19 | Path validation, tests | 5 | MEDIUM |
Pattern: First 3 rounds find the most impactful issues. Rounds 4-15 find the rest. Rounds 16+ are diminishing returns (mostly test coverage and L1 cleanup).
Before reporting round findings, verify:
file:line reference (read the actual source)npx tsc --noEmit returns 0 errorsnpm test shows 0 failuresIf ANY answer is NO → Stop. Complete audit requirements before reporting round results.
scrutinize — Quick outsider-perspective review of a single changemulti-perspective-review — 8-pass deep review for a single changeverification-before-done — Evidence before claim (use per round)systematic-debugging — When a finding reveals a real bug that needs deeper investigationFrequently asked questions
Distilled from 19 rounds of auditing pi-crew on itself (v0.5.5 → v0.5.14): 70 issues fixed, 286 tests added, 9 security improvements, 2 performance improvements.
The source record exposes this install command: npx skills add https://github.com/baphuongna/pi-crew --skill "skills/iterative-audit". Inspect the command and pinned source before running it.
Static rules flagged read-files in the source; the page lists the matching lines and excerpts.
Alternatives
vasilyu1983/AI-Agents-public
Guides iOS testing with XCTest, XCUITest, Swift Testing, simctl, and xcresult. Use when choosing destinations, controlling flakes, or parsing test artifacts for native apps.
steipete/agent-scripts
REQUIRED before ANY `op` command or whenever a task needs an API key, token, password, credential, or secret (OPENAI_API_KEY, ANTHROPIC_API_KEY, deploy tokens, live-test keys). Prompt-free 1Password service-account reads; wrong invocations spam macOS dialogs.
microsoft/Sico
Execute Android UI workflows on a sandbox device, review results, and produce a structured execution report.
mission69b/t2000
Publishing, upgrading, and deploying Sui Move packages. Use this skill when the user needs to publish a package, upgrade a published package, deploy to multiple networks, serialize transactions for multisig signing, run a local Sui network (localnet), prepare for Mainnet launch, monitor production deployments, or debug dry run failures. Also use when the user asks about sui client publish, sui client upgrade, UpgradeCap, upgrade policies, Published.toml, --serialize-output, localnet, mainnet lau