audit
Code quality and compliance audits — dead code detection, PII handling, and SOC 2 readiness
Best use case
audit is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Code quality and compliance audits — dead code detection, PII handling, and SOC 2 readiness
Teams using audit should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/audit/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How audit Compares
| Feature / Agent | audit | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Code quality and compliance audits — dead code detection, PII handling, and SOC 2 readiness
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# Code Quality & Compliance Audit
You are performing code quality and compliance audits on this project. These audits are **read-only** — they report findings but do not modify code. This skill is distinct from `/security-audit` (which focuses on vulnerabilities) and `/dependency-audit` (which focuses on npm packages).
## Available Audit Types
| Key | Audit | Focus |
| ----------- | ------------------- | ----------------------------------------------------------------------- |
| `dead-code` | Dead Code Detection | Unused files, exports, dependencies, and types |
| `pii` | PII Handling Audit | Personal data flows, logging safety, GDPR compliance |
| `soc2` | SOC 2 Readiness | Change management, access control, monitoring, vulnerability management |
## Instructions
### 1. Determine audit scope
If `$ARGUMENTS` is provided, parse it as a comma-separated list of audit keys, or `all` for everything. Otherwise, ask the user which audits to run.
### 2. Load context
- Read `package.json` for project metadata and dependencies
- Read `CLAUDE.md` and `.claude/docs/TypeScript Coding Standard for Mission-Critical Systems.md` if present
- Determine source file scope: all `.ts` files under `src/`
### 3. Execute selected audits
---
### Audit: `dead-code` — Dead Code Detection
Analyze the codebase for unused code that increases maintenance burden and attack surface.
1. **Unused exports**: For each exported function, type, constant, and class in `src/`, search the rest of the codebase for imports of that export. Flag exports that are never imported anywhere (excluding `index.ts` barrel re-exports that are themselves unused).
2. **Unused files**: Identify `.ts` files that are not imported by any other file and are not entry points (`src/index.ts`, test files, config files).
3. **Unused dependencies**: For each package in `dependencies` and `devDependencies` in `package.json`:
- Search `src/` and config files for `import ... from '<package>'` or `require('<package>')`
- Search config files (`.eslintrc*`, `vitest.config.*`, `tsconfig.json`, etc.) for references
- Flag packages with zero references
4. **Unused types**: TypeScript interfaces and type aliases that are defined but never referenced.
5. **Commented-out code**: Search for multi-line commented code blocks (3+ consecutive lines of `//` comments that look like code, or `/* */` blocks containing code patterns).
6. **Dead branches**: Code after `return`, `throw`, `break`, or `continue` statements within the same block.
7. **TODO/FIXME/HACK**: Catalog all TODO, FIXME, and HACK comments with file:line locations — these indicate incomplete or temporary code.
If Knip is available (`npx knip --version` succeeds), also run `npx knip --reporter json` and incorporate its findings.
**Output**: Table of dead code items with file, line, category, and suggested action (remove/review).
---
### Audit: `pii` — PII Handling Audit
Analyze the codebase for personally identifiable information handling and GDPR compliance concerns.
1. **PII field detection**: Search for TypeScript interfaces, types, Zod schemas, and variable declarations containing fields commonly associated with PII:
- Names: `name`, `firstName`, `lastName`, `fullName`, `displayName`
- Contact: `email`, `phone`, `phoneNumber`, `mobile`, `address`, `city`, `state`, `zip`, `postalCode`, `country`
- Identity: `ssn`, `socialSecurityNumber`, `nationalId`, `passport`, `driverLicense`, `dateOfBirth`, `dob`, `birthDate`, `age`
- Financial: `creditCard`, `cardNumber`, `cvv`, `bankAccount`, `iban`, `routingNumber`
- Digital: `ip`, `ipAddress`, `userAgent`, `deviceId`, `mac`, `geolocation`, `latitude`, `longitude`
2. **Branded type check** (Rule 7.3): For each PII field found, check if it uses a branded type (e.g., `Email` instead of raw `string`). Flag raw primitive PII fields.
3. **Logging exposure**: Search all logging statements (`console.log`, `console.info`, `console.warn`, `console.error`, `logger.info`, `logger.warn`, `logger.error`, `logger.debug`) for:
- Direct references to PII-typed variables
- Logging of entire request objects (`logger.info(req)`, `logger.info({ body: req.body })`)
- Logging of entire user objects
- String interpolation containing PII field names
4. **Error message exposure**: Check error handlers and Error constructors for PII in messages. Check HTTP error responses for PII leakage.
5. **Validation at boundaries** (Rule 7.2): For each API endpoint or external input handler that receives PII, verify Zod schema validation is present and is the first operation.
6. **Data flow map**: Generate a text-based map showing:
- Where PII enters the system (API endpoints, file reads, env vars)
- Where PII is stored (database writes, cache, file system)
- Where PII exits the system (API responses, emails, logs, exports)
- Where PII is missing encryption or redaction
**Output**: PII inventory table, compliance gaps, and a data flow summary.
---
### Audit: `soc2` — SOC 2 Readiness Assessment
Evaluate the repository for SOC 2 Trust Services Criteria evidence. Uses `gh` CLI where available for GitHub configuration checks.
1. **Change Management (CC8.1)**:
- Check branch protection on `main`: `gh api repos/{owner}/{repo}/branches/main/protection` (if `gh` is available)
- Verify PR reviews are required
- Verify CI status checks are required before merge
- Search git history for direct pushes to `main` without PRs: `git log --first-parent main --no-merges --oneline`
- Verify CI workflows exist and enforce the coding standard
2. **Access Control (CC6.1-CC6.8)**:
- Check for `.env` files committed to the repository (should be in `.gitignore`)
- Scan source code for hardcoded secrets (API keys, tokens, passwords — same patterns as `/security-audit secrets`)
- Check for `CODEOWNERS` file existence
- Check for Dependabot or Renovate configuration
3. **Monitoring and Logging (CC7.1-CC7.4)**:
- Check for structured logging implementation (Pino, Winston)
- Check for error monitoring integration patterns (Sentry, Datadog imports)
- Check for health check endpoints (`/health`, `/healthz`, `/readyz`)
- Check for request/response logging middleware
4. **Vulnerability Management (CC3.1-CC3.4)**:
- Verify `npm audit` is in CI pipeline
- Check for SAST tools (CodeQL, Semgrep, SonarQube configuration)
- Check for container scanning if Docker is used (Trivy, Snyk)
- Verify dependency update automation (Dependabot, Renovate)
5. **Availability (A1.1-A1.3)**:
- Check for health check endpoint implementations
- Check for runbook/incident documentation in `docs/`
- Check for graceful shutdown handling (`SIGTERM`/`SIGINT` handlers)
- Check for Dockerfile with `HEALTHCHECK`
**Output**: SOC 2 control matrix with status (PASS/FAIL/PARTIAL/NOT APPLICABLE), evidence locations, and gap remediation suggestions.
---
### 4. Generate consolidated report
Output a structured report to the console:
```markdown
# Code Quality & Compliance Audit Report
**Date**: YYYY-MM-DD
**Project**: <name>
**Audits performed**: <list>
## Summary
- Dead code items: N
- PII compliance gaps: N
- SOC 2 controls passing: N/M
## Dead Code Findings
| File | Line | Category | Item | Action |
| ---- | ---- | -------- | ---- | ------ |
## PII Handling Findings
| File | Line | Field | Issue | Severity |
| ---- | ---- | ----- | ----- | -------- |
### PII Data Flow Map
<text-based flow diagram>
## SOC 2 Readiness
| Control | Category | Status | Evidence | Gap |
| ------- | -------- | ------ | -------- | --- |
## Recommendations
1. Prioritized action list
2. ...
---
_Generated by /audit_
```
### 5. Do not modify any files — this is a read-only audit.Related Skills
divek-bi-visual-audit
Visual compliance auditing for DiveK brand identity. Use when reviewing UI screens, component libraries, landing pages, design handoff specs, CSS tokens, or visual QA reports for alignment with DiveK color palette, typography, and cinematic-minimal style direction.
dependency-management-deps-audit
You are a dependency security expert specializing in vulnerability scanning, license compliance, and supply chain security. Analyze project dependencies for known vulnerabilities, licensing issues,...
Cookbook Audit
Audit an Anthropic Cookbook notebook based on a rubric. Use whenever a notebook review or audit is requested.
Compliance Audit
Audit technical controls against compliance framework requirements
codebase-cleanup-deps-audit
You are a dependency security expert specializing in vulnerability scanning, license compliance, and supply chain security. Analyze project dependencies for known vulnerabilities, licensing issues,...
codebase-audit
Performs comprehensive codebase audit checking architecture, tech debt, security, test coverage, documentation, dependencies, and maintainability. Use when auditing a project, assessing codebase health, or asked to audit/analyze the entire codebase.
claude-a11y-audit
Use when reviewing UI diffs, accessibility audits, or flaky UI tests to catch a11y regressions, semantic issues, keyboard/focus problems, and to recommend minimal fixes plus role-based test selectors.
aws-security-audit
Comprehensive AWS security posture assessment using AWS CLI and security best practices
auditor-workflow
Group-level implementation audit workflow for auditor agents. Handles loading project rules, reading connected phases, reviewing code reviews, checking deferred items, cross-phase impact analysis, verification, and structured reporting to the orchestrator. Invoke this skill as your first action — not user-invocable.
auditor-gate
Apply final governance and release-gate checks to a judged change set by reading `handoff.json`, `verdict.json`, optional eval evidence, and emitting machine-readable `audit.json` with `gate` status. Use when implementation already has a judge verdict and a separate auditor must decide landability (`pass`, `fail`, or `needs-human`) without modifying source files.
auditing-accessibility-wcag
Checks components and pages for WCAG 2.1 accessibility violations. Use when the user asks about a11y, WCAG compliance, screen readers, aria labels, keyboard navigation, or accessible patterns.
audit-rules
Audit Claude Code rule files for quality and compliance. Use when creating or validating .claude/rules/*.md files, or troubleshooting rule loading issues.