---
name: audit
description: Split the project into areas and audit each one independently.
disable-model-invocation: true
---

Run a comprehensive code audit on this project. The audit works in three phases: map, sweep, and summarize.

Phase 1 - Map

Start by understanding the project layout. Use Glob and Read on key entry points (package.json, README, directory structure) to identify every meaningful code area. An area is a directory or group of closely related files that can be reviewed independently. Typical area boundaries include:

- A top-level module directory (e.g., `source/services/`, `source/ui/`, `source/utils/`)
- A client package (e.g., `clients/web/src/`, `clients/desktop/src/main/`)
- A config/build layer (e.g., build scripts, config files)
- A subdirectory with a clear single responsibility

Aim for 5-20 areas depending on project size. Each area should be small enough for thorough file-by-file review (roughly 5-30 files). If a directory has too many files, split it into sub-areas. If two small directories are tightly coupled, combine them.

Print the full area plan before proceeding. Format:

```
Area Plan (N areas):
1. path/to/area/ - Brief description (estimated file count)
2. path/to/area/ - Brief description (estimated file count)
...
```

Phase 2 - Sweep

Call `Agent_Audit` for each area in the plan. Pass the area path and description as the `area` parameter. If the user specified focus areas via $ARGUMENTS, pass them as the `checklist` parameter to every call.

Do not skip areas. Do not merge areas to save time. Each area gets its own independent agent call so the review starts fresh with full attention.

When the user provides arguments, interpret them as checklist focus areas. For example, `/audit error-handling, security` means every area should prioritize error handling and security checks.

Phase 3 - Summarize

After all areas are reviewed, compile a single audit report. Deduplicate findings that appear across areas (same root cause in shared code). Rank all findings by severity.

Print the final report in this format:

```
# Audit Report

Project: (project name)
Areas reviewed: N
Total files reviewed: (sum from all areas)

## Critical (must fix)
- [file:line] Finding. (from area: X)

## Important (should fix)
- [file:line] Finding. (from area: X)

## Minor (nice to fix)
- [file:line] Finding. (from area: X)

## Cross-cutting patterns
- Observations that appeared in multiple areas (e.g., inconsistent error handling style, recurring cleanup omissions).

## Clean areas
- Areas or subsystems that looked solid.

## Summary
One paragraph overall assessment: the project's health, the most impactful areas to address, and any systemic patterns worth a targeted cleanup pass.
```

If the project is generally clean, say so. Do not inflate severity or invent issues to make the report look thorough.
