# Code Audit

> Reviews a codebase for bugs, design issues, and code cleanliness problems with specific file paths and line numbers. Use when auditing code quality, finding bugs, doing a code review, or reviewing a project for issues. Writes issues to `.issues/`.

- Skill: `philoserf/code-audit-2` (Agent Skill)
- Install (CLI): `npx get-skill add philoserf/code-audit-2`
- Raw SKILL.md: https://api.skillmd.com/api/skills/philoserf/code-audit-2/raw
- Safety review: pending (external: skill-scanner PASS, skillspector PASS)
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Security
- Author: philoserf (https://skillmd.com/u/philoserf)
- Updated: 2026-09-22
- Page: https://skillmd.com/skills/philoserf/code-audit-2

---


Review this codebase for bugs, design issues, and code cleanliness problems. Be specific and cite file paths and line numbers.

Scope the review to `$ARGUMENTS` if provided, otherwise review the entire project. Examples: `src/auth/`, `lib/api.ts`, `security`, `tests/`.

Skip vendored dependencies, build output, generated/minified code, and lockfiles (e.g. `node_modules/`, `dist/`, `build/`, `vendor/`, `*.min.js`, `package-lock.json`, `go.sum`).

## What to look for

Prioritize by severity:

| Severity     | Category                                                  |
| ------------ | --------------------------------------------------------- |
| **Critical** | Security vulnerabilities, data loss, crashes              |
| **High**     | Correctness bugs, missing error handling, race conditions |
| **Medium**   | Design issues, code smells, missing validation            |
| **Low**      | Style inconsistencies, naming, minor cleanup              |

Common patterns worth checking for (not exhaustive):

- **Correctness** — off-by-one/boundary errors, null/undefined derefs, wrong comparison (`==` vs `===`, identity vs value), operator-precedence mistakes.
- **Error handling** — swallowed exceptions, ignored return/error values, bare `except`/`catch`, no rollback on partial failure.
- **Resources** — leaked handles/connections/goroutines, missing `defer`/`finally`/close, unbounded growth.
- **Concurrency** — unsynchronized shared state, races, deadlocks, missing `await` on async calls.
- **Security** — unvalidated input, injection (SQL/command/path), secrets in source, missing authz checks.
- **API/contract** — callers not updated for a signature change, nullable returns treated as non-null, silent type coercion.

## Process

For each issue found:

1. Check for duplicates in both GitHub issues (`gh issue list`) and the local `.issues/` directory. GitHub issues lack structured `file:line` metadata — search titles and bodies for the file path instead (`gh issue list --search "<path>"`). If `gh` is unavailable, unauthenticated, or errors (non-GitHub, offline, or unconfigured repo), skip the GitHub dedup step and note this in the final summary instead of failing.
2. Skip if a matching issue already exists — match by the same `file:line` plus the same issue category (e.g., another "missing null check" at that location)
3. Otherwise, create a markdown file in `.issues/` with a descriptive kebab-case filename

Create `.issues/` if it doesn't already exist. For very large scopes that would produce many files, prioritize Critical/High severity issues first, and traverse deliberately — entry points and core modules first, then remaining directories one at a time — so coverage is systematic rather than a random sample.

Each issue file should follow this format:

```text
# Title

**Severity:** critical | high | medium | low
**Location:** `file:line`

## Description

What's wrong and why it matters.

## Suggested fix

Concrete recommendation.
```

## Summary

After creating all issue files, output a summary:

```text
| # | Severity | File:Line | Issue |
|---|----------|-----------|-------|
| 1 | high     | src/a.ts:42 | Missing null check |
| 2 | medium   | lib/b.py:17 | Bare except clause |

Total: {N} issues ({critical} critical, {high} high, {medium} medium, {low} low)
Files created in .issues/
```

## Do not use when

- Reviewing harness customizations (skills, hooks, settings) — use `/doctor`, or `skill-cleaner` for skill hygiene
- Reviewing a specific staged or branch diff — use `/code-review`

