apex-bug-hunter
Skill1 starsChanged 5 months agoMITView on GitHub
Execute deep multi-pass bug hunting, differential pull request reviews, branch comparisons, full-repository architectural audits, tight-loop bug diagnosis, performance regression bisection, and zero-regression fixes. Trigger automatically whenever the user asks to hunt bugs, review a pull request (PR #N), audit a branch against main, audit the entire main branch or codebase, diagnose production regressions or flaky tests, verify an engineering report, audit MCP or OAuth protocol compliance, or fix severe defects.
In this repository19 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- agy-skill-installerSkill
- arsSkill
- browser-triageSkill
- claude-md-initSkill
- delink-githubSkill
- gemini-skill-packagerSkill
- gh-readySkill
- indian-legal-verificationSkill
- local-systematic-verification-ocrSkill
- magento-team-leadSkill
- merge-gateSkill
- motioncraftSkill
- pdf-vector-engineSkill
- presscraftSkill
- score2mdSkill
- skill-shipSkill
- wpcraftSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
20 rules. About 0 are common, 7 are distinctive, and 13 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈7
Distinctive · estimate
This author's own choices. Worth a look.
13
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 26
Before inspecting files or emitting any analysis, engage all four cognitive locks.
- Distinctive: line 36
Never skim file headers, guess function behavior from identifiers, or skip passes after finding an early bug.
- Very specific: line 38
Never emit placeholder comments (// ...
- Very specific: line 42
Never recursively invoke apex-bug-hunter or spawn nested review sub-agents that re-trigger this skill.
- Very specific: line 46
Never cite a file:line, symbol name, commit SHA, test result, or specification clause without reading the exact lines at current HEAD first.
- Very specific: line 48
Every bug finding must include a verbatim 1-5 line quote from the target file at HEAD.
- Very specific: line 50
Before presenting any Stage 1 or Stage 2 report, run node scripts/verify-citations-and-ast-seams.js <report-file> (or verify every …
- Very specific: line 54
Never equate a passing pnpm verify, npm run build, tsc, or vitest exit code 0 with system correctness.
- Very specific: line 56
Unvalidated Test Harness (
HACK-01): Check whether tests initialized schema validation before invoking handlers (for example, calling … - Very specific: line 58
Dead Helper Code (
HACK-05): Verify newly created helper functions (pagination cursors, fuzzy matchers, sanitizers) are imported and … - Very specific: line 60
Historical Fabrication (
HACK-06): Never claim an earlier commit fixed a defect without verifying current HEAD at file:line. - Very specific: line 62
Silent Fallbacks: Check whether missing or invalid parent IDs, foreign keys, or enum values silently fall back to root placement (parentId: …
- Distinctive: line 91
Stop and wait for the user's explicit execution command before mutating production files.
- Very specific: line 96
Remove 100% of temporary [DEBUG-xxxx] probes, run cold verification suites and static contract verifiers, and package changes into granular …
- Very specific: line 106
Pass 3: Contract, Protocol, and Output Schema Parity Audit: Verify 100% return-branch structuredContent parity across all tools declaring …
- Distinctive: line 167
Follow the summary table with a detailed section per bug containing:
- Distinctive: line 181
After executing approved fixes, emit:
- Distinctive: line 193
When commanded to execute fixes:
- Distinctive: line 197
Create a minimal reproduction test at that seam that fails prior to code modification.
- Very specific: line 201
Verify the reproduction test passes and all [DEBUG-xxxx] probes are removed.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Apex Bug Hunter
A deterministic, multi-stage bug-hunting, differential code review, tight-loop root-cause diagnosis, and zero-regression remediation skill. It unifies the CodeRabbit 4-Stage AST and Call-Graph Review Pipeline, Obra Superpowers Systematic Debugging (systematic-debugging, root-cause-tracing, defense-in-depth, condition-based-waiting, verification-before-completion), Matt Pocock's Engineering Discipline (diagnosing-bugs hard phase gates, code-review orthogonal axis separation, tdd seam and anti-pattern rules, improve-codebase-architecture deep-module deletion test, and retro environment hardening), Andrej Karpathy's 4 Surgical Coding Laws, and Ponytail Zero-Regression Engineering.
When to Use
- Auditing a Pull Request (
PR #N), commit range, or uncommitted working-tree diff for bugs, contract drift, or security flaws - Comparing a feature or fix branch against
mainororigin/main - Performing a whole-branch or full-repository architectural, boundary, contract, concurrency, and state-machine audit
- Diagnosing a specific hard bug, flaky test, or performance regression using a tight reproduction loop and
git bisect - Auditing an AI agent's engineering report or "green build" claim against actual
HEADsource code and runtime behavior - Executing surgical, zero-regression fixes with cold verification and granular GPG-signed commits
1. Cognitive Locks: Anti-Sycophancy, Anti-Short-Circuiting, and Anti-Hallucination
Before inspecting files or emitting any analysis, engage all four cognitive locks. These locks apply with maximum strictness to fast or lightweight models (including Gemini Flash). For full enforcement criteria, read references/anti-reward-hacking-and-verification-locks.md.
1.1 Strict Prohibition of AI Sycophancy
- Ban all performative agreement, flattery, conversational filler, and premature celebratory claims (such as "Great question!", "Your code is well-structured!", or "Fixed flawlessly!").
- State findings, root causes, and verification outputs plainly with exact
file:lineevidence.
1.2 Strict Prohibition of AI Short-Circuiting (Flash-Model Lock)
- Never skim file headers, guess function behavior from identifiers, or skip passes after finding an early bug.
- Never emit placeholder comments (
// ... existing code,// TODO) or bulk summaries ("Reviewed the remaining 8 files and found no issues"). - For every audited file or handler, record an explicit inspection receipt (
file:line_start-line_end, input schema, output schema, and verified branches) before moving to the next file. - Never recursively invoke
apex-bug-hunteror spawn nested review sub-agents that re-trigger this skill.
1.3 Strict Prohibition of AI Hallucination (Citation Proof Lock)
- Never cite a
file:line, symbol name, commit SHA, test result, or specification clause without reading the exact lines at currentHEADfirst. - Every bug finding must include a verbatim 1-5 line quote from the target file at
HEAD. - Before presenting any Stage 1 or Stage 2 report, run
node scripts/verify-citations-and-ast-seams.js <report-file>(or verify everyfile:line:symboltuple) to prove 100% of cited paths, line numbers, and identifiers exist on disk.
1.4 Defeat the Green Build Fallacy
Never equate a passing pnpm verify, npm run build, tsc, or vitest exit code 0 with system correctness. Always audit for these six failure modes:
- Unvalidated Test Harness (
HACK-01): Check whether tests initialized schema validation before invoking handlers (for example, callingawait client.listTools()beforeclient.callTool()in@modelcontextprotocol/sdk). - Dead Helper Code (
HACK-05): Verify newly created helper functions (pagination cursors, fuzzy matchers, sanitizers) are imported and called inside live production route and tool handlers. - Historical Fabrication (
HACK-06): Never claim an earlier commit fixed a defect without verifying currentHEADatfile:line. - Silent Fallbacks: Check whether missing or invalid parent IDs, foreign keys, or enum values silently fall back to root placement (
parentId: null) or default objects instead of throwingNOT_FOUNDorINVALID_ID. - Implementation-Coupled Internal Mocks (
HACK-08): Flag tests that mock internal repository or service modules instead of real system boundaries. - Tautological Assertions (
HACK-09): Flag tests that compute expected values using the same implementation logic under test rather than independent spec literals.
2. Universal Scope Resolution, Complexity Router, and Two-Stage Gate
Resolve the operational scope from the user's request before starting Pass 1. Run scripts/preflight-diff-and-boundary-scan.sh (or node scripts/preflight-diff-and-boundary-scan.js) and node scripts/verify-mcp-and-schema-parity.js to gather deterministic baseline telemetry.
2.1 Four-Lane Operational Scope & Complexity Router
| Mode | Trigger Condition | Inspection Scope |
| Pull Request Mode | User specifies PR #N or a PR URL | Audit git diff <base>...<head>, all PR commits, full PR/issue comment threads, and all upstream callers and downstream callees in the AST symbol graph |
| Branch & WIP Diff Mode | User specifies a branch name or local diff | Audit git diff origin/main...<branch> PLUS uncommitted staged and working-tree changes (git diff HEAD and git status --porcelain) plus transitive call-graph dependencies |
| Whole-Branch / Repository Mode | User specifies main, whole repo, or full audit | Audit full system architecture, entry boundaries, schemas, state machines, concurrency locks, persistence layers, and test harnesses across all modules |
| Tight-Loop Bug / Perf Diagnosis Mode | User reports a specific failing symptom, flake, or slow endpoint | Execute the 6-Phase Hard Gate Tight-Loop Diagnosis (references/scientific-root-cause-and-ponytail-fixes.md): build a deterministic red command (or baseline timing + git bisect run) before forming any hypothesis |
| Protected Zero-Touch Path Lock | Protected paths exist (such as OAuth 2.1 routes, token issuers, or production auth configs) | Enforce a strict 0-byte diff guard (git diff and git diff HEAD must be 0 bytes on all protected paths) |
2.2 Two-Stage Command Gate
Operate in a strict two-stage gate unless the user explicitly commands immediate code mutation in their initial prompt:
- Stage 1: Deep Audit and Zero-Regression Fix Blueprint (Default):
- Execute the complete 8-Pass Inspection Pipeline across the resolved scope.
- Assign every confirmed defect a deterministic identifier (
BUG-01,BUG-02, ...) ordered by severity (P0 BLOCKER,P1 CRITICAL,P2 MAJOR,P3 MINOR). - Separate findings across three orthogonal axes (
Axis 1: Runtime & State Correctness,Axis 2: Protocol & Spec Compliance,Axis 3: Standards & Module Depth) so passing conventions never mask broken behavior. - Trace the exact
file:linesymptom and backward root cause, verify disconfirming evidence, and engineer a complete Zero-Regression Surgical Fix Blueprint with exact replacement code and blast-radius proof. - Stop and wait for the user's explicit execution command before mutating production files.
- Stage 2: Surgical Execution, Cold Verification, and GPG Commit (Triggered on "Fix it" or "Execute"):
- Agree on the public test seam first, write or run the failing reproduction test at that seam, and verify it fails for the exact expected reason.
- Apply approved surgical fixes adhering strictly to Karpathy's 4 Surgical Coding Laws.
- Remove 100% of temporary
[DEBUG-xxxx]probes, run cold verification suites and static contract verifiers, and package changes into granular GPG-signed commits (git commit -S).
3. The 8-Pass Inspection Pipeline
Execute all eight passes in sequence. Do not skip passes even if an early pass discovers a blocker:
- Pass 1: Governance, Invariants, and External Specification Grounding: Read
AGENTS.md,CLAUDE.md,CODING_STANDARDS.md,GLOSSARY.md,INVARIANTS.md,HALL_OF_SHAME.md,.out-of-scope/, and official protocol specifications (MCP2025-06-18/2025-11-25, OAuth 2.1, RFC 8707). - Pass 2: Differential Line-Deletion (
-), Working-Tree, and Boundary Validation Audit: Inspect deleted lines againstDEL-01..08, apply Ousterhout's Deep-Module Deletion Test, and trace AST symbol blast radius. - Pass 3: Contract, Protocol, and Output Schema Parity Audit: Verify 100% return-branch
structuredContentparity across all tools declaringoutputSchema, enforce array-level truncation, verifyisError: true, deep-clone viastructuredClone, and enforce zero UTF-8 BOM. - Pass 4: State Machine, Hierarchy, Collision, and Idempotency Audit: Verify pure reads, parent existence, trash-batch hints, cycle detection (
A -> B -> A), sibling name collision (CONFLICT), multi-match disambiguation (AMBIGUOUS), active-first resolution, wired pagination cursors, and atomicclientRequestIdlocking. - Pass 5: Concurrency, Async Race Conditions, and
condition-based-waitingAudit: Detect TOCTOU races, enforce atomic database operations (SELECT ... FOR UPDATEorINSERT ... ON CONFLICT), and replace arbitrary sleeps (setTimeout,waitForTimeout) with explicit state condition predicates. - Pass 6: Security, Tenant Isolation, Error Sanitization, and Secret Redaction Audit: Verify composite
(owner_id, id)tenant lookups returningNOT_FOUNDon foreign entities, enforce grant-tier field redaction, sanitize raw database errors, and enforceREDACT-01secret scrubbing in all captured logs. - Pass 7: Test-Harness Integrity and Seam Audit: Confirm test suites invoke real transport clients with
await client.listTools()initialization, agree on public test seams, flag internal mocks (HACK-08), flag tautological assertions (HACK-09), and enforce the Missing-Seam Honesty Rule (HACK-11). - Pass 8: Ponytail Zero-Regression Fix Synthesis and
/retroHardening: Adhere to Obra's Iron Law (no fix without root-cause proof), apply the 3-Strike Halt Rule, enforce 4-layer defense-in-depth, obey Karpathy's 4 laws, package into GPG-signed commits, and convert recurring failures into automated linter or test checks.
4. Progressive Disclosure Reference Map
Load these auxiliary references when executing specific audit passes or tooling tasks:
references/differential-call-graph-audit.md: 4-stage CodeRabbit pipeline, working-tree WIP inspection, DEL-01..08 checklist, Ousterhout's Deep-Module Deletion Test, and Fowler's 12 Code Smells baseline.references/scientific-root-cause-and-ponytail-fixes.md: Matt Pocock's 6-Phase Tight-Loop Hard Gate Table (diagnosing-bugs), Performance Regression Bisection (git bisect run), Obra'scondition-based-waitingasync race remediation, and/retrodeterministic environment hardening.references/anti-reward-hacking-and-verification-locks.md: HACK-01 through HACK-12 taxonomy, Low-Parameter / Flash-Model Anti-Short-Circuiting Lock, and 6-Step Cold Verification Protocol.references/external-protocol-and-mcp-audit.md: MCP 2025 specification invariants, per-branchstructuredContentverification, OAuth 2.1 and RFC 8707 checks, composite tenant lookups, and REDACT-01 secret scrubbers.scripts/preflight-diff-and-boundary-scan.sh: POSIX shell preflight scanner for scope resolution, working-tree WIP diffs, protected-path 0-byte diff lock, and secret scanning.scripts/preflight-diff-and-boundary-scan.js: Cross-platform Node.js preflight scanner mirroring all shell scanner checks.scripts/verify-mcp-and-schema-parity.js: Node.js static analyzer detecting balanced-brace per-returnstructuredContentomissions, dead helpers, internal mocks, and tautological assertions.scripts/verify-citations-and-ast-seams.js: Node.js deterministic anti-hallucination, anti-short-circuiting, and anti-sycophancy verifier.
5. Three-Axis Orthogonal Verdict Separation
Findings are evaluated and reported across three independent, unblended axes:
| Axis | Domain | Severity Range | Failure Gate |
| Axis 1: Runtime & State Correctness | Data corruption, crash, TOCTOU race, missing tenant isolation, unhandled rejection | P0 BLOCKER to P2 MAJOR | Any P0 or P1 blocks PR merge and release |
| Axis 2: Protocol & Spec Compliance | Missing structuredContent, invalid OAuth flow, schema drift, unredacted secrets | P0 BLOCKER to P2 MAJOR | Any spec mismatch blocks certification |
| Axis 3: Standards & Module Depth | Fowler code smell, shallow module interface, missing public test seam, dead helper | P2 MAJOR to P3 MINOR | Tracked for scheduled refactoring |
6. Deterministic Severity Classification
| Level | Severity | Definition | Remediation Window |
| P0 | BLOCKER | Security breach, data loss, cross-tenant leak, or fatal crash in core flow | Immediate halt, fix before deployment |
| P1 | CRITICAL | Protocol contract violation, unhandled rejection, or race condition | Fix required prior to PR merge |
| P2 | MAJOR | Missing boundary validation, dead helper, or missing public test seam | Fix required before next minor release |
| P3 | MINOR | Advisory code smell, sub-optimal query index, or imprecise error text | Scheduled backlog cleanup |
7. Required Output Structure
Stage 1 Output: Bug Hunt and Zero-Regression Fix Blueprint
For each confirmed finding, output a structured table and blueprint block:
| Bug ID | Axis | Severity | Pass | Location (file:line) | Summary | Blast Radius |
BUG-01 | Axis 2 | P0 BLOCKER | Pass 3 | src/tools/items.ts:142 | Missing structuredContent on empty search branch | client.callTool crashes on schema validation |
Follow the summary table with a detailed section per bug containing:
- Symptom and Root-Cause Trace: Exact backward data-flow trace from failure point to origin.
- Verbatim Quote at HEAD: 1-5 line physical code quote from the file at current
HEAD. - Disconfirming Evidence Check: Proof that no upstream guard or middleware mitigates the bug.
- Surgical Fix Blueprint: Exact
file:linereplacement code and caller/callee blast-radius verification. - Falsifiable Verification Command: The exact test or runtime command that fails before the fix and passes after.
Stage 2 Output: Remediation and Verification Record
After executing approved fixes, emit:
- Commit Record: Exact commit SHA, subject line, and
git show --statoutput. - Cold Verification Evidence: Raw terminal output of the verification command suite with exit codes.
- Post-Change Visualization: 5-point protocol: Target Boundary, Prior Behavior, Current Behavior, Downstream Impact, Unverified Scope.
- HALL_OF_SHAME.md Update: Confirm the regression ledger was updated in the same commit as the fix.
8. Stage 2 Remediation Protocol
When commanded to execute fixes:
- Agree on the public test seam first; avoid internal-module mock tests.
- Create a minimal reproduction test at that seam that fails prior to code modification.
- Apply the exact surgical replacement code from the approved blueprint adhering to Karpathy's 4 laws.
- Verify the reproduction test passes and all
[DEBUG-xxxx]probes are removed. - Execute full cold test and build suites (
npm test,npm run build,pnpm verify). - Record granular, GPG-signed commits (
git commit -S) using Conventional Commit format with zero AI attribution trailers.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

