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.
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).
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).
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
Unused types: TypeScript interfaces and type aliases that are defined but never referenced.
Commented-out code: Search for multi-line commented code blocks (3+ consecutive lines of // comments that look like code, or /* */ blocks containing code patterns).
Dead branches: Code after return, throw, break, or continue statements within the same block.
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.
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
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.
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
Error message exposure: Check error handlers and Error constructors for PII in messages. Check HTTP error responses for PII leakage.
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.
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.
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
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
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
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)
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:
# 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.
Converted and distributed by TomeVault — claim your Tome and manage your conversions.
1---2name: audit-83description: Comma-separated list of audit types (e.g., 'dead-code,pii,soc2') or 'all'. If omitted, you will be asked. Use when this capability is needed.4---56# Code Quality & Compliance Audit78You 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).910## Available Audit Types1112| Key | Audit | Focus |13|-----|-------|-------|14| `dead-code` | Dead Code Detection | Unused files, exports, dependencies, and types |15| `pii` | PII Handling Audit | Personal data flows, logging safety, GDPR compliance |16| `soc2` | SOC 2 Readiness | Change management, access control, monitoring, vulnerability management |1718## Instructions1920### 1. Determine audit scope2122If `$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.2324### 2. Load context2526- Read `package.json` for project metadata and dependencies27- Read `CLAUDE.md` and `.claude/docs/TypeScript Coding Standard for Mission-Critical Systems.md` if present28- Determine source file scope: all `.ts` files under `src/`2930### 3. Execute selected audits3132---3334### Audit: `dead-code` — Dead Code Detection3536Analyze the codebase for unused code that increases maintenance burden and attack surface.37381. **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).39402. **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).41423. **Unused dependencies**: For each package in `dependencies` and `devDependencies` in `package.json`:43 - Search `src/` and config files for `import ... from '<package>'` or `require('<package>')`44 - Search config files (`.eslintrc*`, `vitest.config.*`, `tsconfig.json`, etc.) for references45 - Flag packages with zero references46474. **Unused types**: TypeScript interfaces and type aliases that are defined but never referenced.48495. **Commented-out code**: Search for multi-line commented code blocks (3+ consecutive lines of `//` comments that look like code, or `/* */` blocks containing code patterns).50516. **Dead branches**: Code after `return`, `throw`, `break`, or `continue` statements within the same block.52537. **TODO/FIXME/HACK**: Catalog all TODO, FIXME, and HACK comments with file:line locations — these indicate incomplete or temporary code.5455If Knip is available (`npx knip --version` succeeds), also run `npx knip --reporter json` and incorporate its findings.5657**Output**: Table of dead code items with file, line, category, and suggested action (remove/review).5859---6061### Audit: `pii` — PII Handling Audit6263Analyze the codebase for personally identifiable information handling and GDPR compliance concerns.64651. **PII field detection**: Search for TypeScript interfaces, types, Zod schemas, and variable declarations containing fields commonly associated with PII:66 - Names: `name`, `firstName`, `lastName`, `fullName`, `displayName`67 - Contact: `email`, `phone`, `phoneNumber`, `mobile`, `address`, `city`, `state`, `zip`, `postalCode`, `country`68 - Identity: `ssn`, `socialSecurityNumber`, `nationalId`, `passport`, `driverLicense`, `dateOfBirth`, `dob`, `birthDate`, `age`69 - Financial: `creditCard`, `cardNumber`, `cvv`, `bankAccount`, `iban`, `routingNumber`70 - Digital: `ip`, `ipAddress`, `userAgent`, `deviceId`, `mac`, `geolocation`, `latitude`, `longitude`71722. **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.73743. **Logging exposure**: Search all logging statements (`console.log`, `console.info`, `console.warn`, `console.error`, `logger.info`, `logger.warn`, `logger.error`, `logger.debug`) for:75 - Direct references to PII-typed variables76 - Logging of entire request objects (`logger.info(req)`, `logger.info({ body: req.body })`)77 - Logging of entire user objects78 - String interpolation containing PII field names79804. **Error message exposure**: Check error handlers and Error constructors for PII in messages. Check HTTP error responses for PII leakage.81825. **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.83846. **Data flow map**: Generate a text-based map showing:85 - Where PII enters the system (API endpoints, file reads, env vars)86 - Where PII is stored (database writes, cache, file system)87 - Where PII exits the system (API responses, emails, logs, exports)88 - Where PII is missing encryption or redaction8990**Output**: PII inventory table, compliance gaps, and a data flow summary.9192---9394### Audit: `soc2` — SOC 2 Readiness Assessment9596Evaluate the repository for SOC 2 Trust Services Criteria evidence. Uses `gh` CLI where available for GitHub configuration checks.97981. **Change Management (CC8.1)**:99 - Check branch protection on `main`: `gh api repos/{owner}/{repo}/branches/main/protection` (if `gh` is available)100 - Verify PR reviews are required101 - Verify CI status checks are required before merge102 - Search git history for direct pushes to `main` without PRs: `git log --first-parent main --no-merges --oneline`103 - Verify CI workflows exist and enforce the coding standard1041052. **Access Control (CC6.1-CC6.8)**:106 - Check for `.env` files committed to the repository (should be in `.gitignore`)107 - Scan source code for hardcoded secrets (API keys, tokens, passwords — same patterns as `/security-audit secrets`)108 - Check for `CODEOWNERS` file existence109 - Check for Dependabot or Renovate configuration1101113. **Monitoring and Logging (CC7.1-CC7.4)**:112 - Check for structured logging implementation (Pino, Winston)113 - Check for error monitoring integration patterns (Sentry, Datadog imports)114 - Check for health check endpoints (`/health`, `/healthz`, `/readyz`)115 - Check for request/response logging middleware1161174. **Vulnerability Management (CC3.1-CC3.4)**:118 - Verify `npm audit` is in CI pipeline119 - Check for SAST tools (CodeQL, Semgrep, SonarQube configuration)120 - Check for container scanning if Docker is used (Trivy, Snyk)121 - Verify dependency update automation (Dependabot, Renovate)1221235. **Availability (A1.1-A1.3)**:124 - Check for health check endpoint implementations125 - Check for runbook/incident documentation in `docs/`126 - Check for graceful shutdown handling (`SIGTERM`/`SIGINT` handlers)127 - Check for Dockerfile with `HEALTHCHECK`128129**Output**: SOC 2 control matrix with status (PASS/FAIL/PARTIAL/NOT APPLICABLE), evidence locations, and gap remediation suggestions.130131---132133### 4. Generate consolidated report134135Output a structured report to the console:136137```markdown138# Code Quality & Compliance Audit Report139140**Date**: YYYY-MM-DD141**Project**: <name>142**Audits performed**: <list>143144## Summary145- Dead code items: N146- PII compliance gaps: N147- SOC 2 controls passing: N/M148149## Dead Code Findings150| File | Line | Category | Item | Action |151|------|------|----------|------|--------|152153## PII Handling Findings154| File | Line | Field | Issue | Severity |155|------|------|-------|-------|----------|156157### PII Data Flow Map158<text-based flow diagram>159160## SOC 2 Readiness161| Control | Category | Status | Evidence | Gap |162|---------|----------|--------|----------|-----|163164## Recommendations1651. Prioritized action list1662. ...167168---169*Generated by /audit*170```171172### 5. Do not modify any files — this is a read-only audit.173174---175> Converted and distributed by [TomeVault](https://tomevault.io/claim/michaelleehobbs) — claim your Tome and manage your conversions.176<!-- tomevault:4.0:skill_md:2026-04-13 -->