Code audit

From benthamite/dotfiles · View interactive version

Code audit is an AI agent skill from the GitHub repository benthamite/dotfiles. Audit code for actual defects, including bugs, application security issues, error handling gaps, and correctness problems. Not for readability, architecture, test coverage, performance-only, or broad environment security reviews.

How to use this skill

Skill file

Code audit

Review the scope named in the user's request or actual invocation arguments for correctness, security, and robustness issues. Use $ARGUMENTS only when the active runtime supplies it; do not treat an unsubstituted placeholder as a path. Find defects with a concrete supported failure or threat model, not generic hardening opportunities.

If the user explicitly asks to fix confirmed findings, whether in natural language or with --accept, audit first, then fix all confirmed findings whose fix is clear and within the requested scope. Do not broaden into refactors, feature work, or speculative defensive rewrites. If a finding needs product judgment, credentials, or an externally visible action, report it as unresolved instead of guessing. Run the relevant verification for the project and commit only the accepted fixes.

Workflow

  1. Resolve the scope: use the explicit files, directories, diff, PR, or issue named in the user's request first, then any actual invocation scope; only when neither names a scope should you default to the current project. Read project instructions and inspect the working tree, including staged changes. Identify the reviewed revision and distinguish new regressions from pre-existing defects for diff/PR reviews. Follow relevant callers outside a named file to confirm behavior without silently broadening the deliverable.
  2. Identify verification: inspect the project's docs and config for the right checks before changing code. Examples: byte-compile and ERT for Elisp, typecheck/lint/test commands for typed or compiled projects, dependency scanners when the audit includes package risk. Inspect commands and fixtures before running them: an audit does not authorize production probes, credential access, downloads/installs, migrations or externally visible writes merely because they occur in a test script. Use safe isolated reproductions and report inaccessible evidence.
  3. Read real code paths: inspect the implementation, callers, inputs, and persistence boundaries. Use available subagents or parallel searches for broad codebases, but do not infer findings from filenames alone. Audit-only checks must not rewrite tracked files or update expected snapshots. Re-check the reviewed revision and affected edits before implementing a finding; concurrent changes may invalidate the diagnosis.
  4. Confirm each finding: trace a concrete failure mode, bad input, race, leak, or attack path through actual callers and guarantees. State prerequisites, expected versus observed behavior, impact and confidence. Distinguish a reproduced failure from a well-supported static finding or an unresolved hypothesis. Verify unfamiliar API contracts and current vulnerability/version claims against authoritative sources; do not infer exploitability from a package name or advisory count alone. Deduplicate symptoms sharing one root cause.
  5. Report or fix: for an audit-only request, report findings in the format below and offer to fix critical and bug-level issues. When the user asked for fixes in natural language or with --accept, apply the confirmed in-scope fixes, verify them, and commit the result.
  6. Verify fixes: reproduce the supported failing behavior before changing it when safe, then check that exact behavior after the change. Add a focused regression where practical, check analogous paths affected by the same implementation, and run relevant project checks. A compile/lint pass alone is not evidence that the defect is gone. Preserve unrelated edits and staged work; commit each logical fix according to project policy, using only owned changes. Report partial outcomes and unmeasured runtime gaps without calling every finding resolved. Do not push or publish as an implicit audit step.

What to look for

Correctness

Security

Error handling

Data integrity

What NOT to flag

Output format

Use the host/project's required review schema when one exists. Otherwise organize confirmed findings by impact, omitting empty categories:

  1. Critical: issues that could cause data loss, security breaches, or silent corruption in production
  2. Bugs: things that are demonstrably wrong or will fail under specific conditions
  3. Fragile: code that works now but will fail under a concrete supported input, configuration, dependency, or environment transition
  4. Minor: low-impact confirmed defects, not style or speculative cleanup

For each finding, include:

Then include:

At the end of an audit-only request, offer to fix the critical and bug-level issues. When the user asked for fixes in natural language or with --accept, summarize the fixes, verification, unresolved findings, and commit hash.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.