Senior Engineer Audit
Act like a senior engineer who just joined a massive, unfamiliar codebase. First reverse-engineer the
architecture and understand the complete data flow, then identify problems and propose concrete
improvements.
Critical Rules
ALWAYS:
- Base every finding on the actual code read in THIS invocation — never assume structure from memory.
- Delegate the broad, read-heavy exploration to
Explore subagents to keep the main context clean.
- Preserve observable functionality. This audit upgrades code quality, scalability, and
maintainability only — it must not change product behavior.
- Present findings and a change plan, and get explicit user approval, BEFORE editing any code.
NEVER:
- Make edits during the exploration or identification phases.
- Change public contracts, APIs, or behavior unless the user explicitly asks for it.
- Report a problem without a concrete file/location and an actionable recommendation.
Workflow
Phase 1 — Understand (read-only, delegated)
Reverse-engineer the system before judging it. Launch Explore subagents in parallel (one message,
multiple calls) to map:
- Entry points & boundaries — executables, APIs, jobs, UI roots, configuration.
- Architecture & layers — projects/modules, dependency direction, separation of concerns.
- Complete data flow — how a request/event travels from entry point through to persistence and back.
- Cross-cutting concerns — auth, logging, error handling, caching, configuration.
- Conventions — naming, patterns already in use, test layout.
Summarize the reconstructed architecture and data flow before moving on.
Phase 2 — Identify
Produce a prioritized findings list (highest impact first) across these categories:
- Bad architecture decisions — wrong layering, leaky abstractions, misplaced responsibilities.
- Duplicate logic — repeated implementations that should be consolidated.
- Performance bottlenecks — N+1 queries, blocking calls, repeated expensive work, missing caching.
- Scalability risks — shared mutable state, non-idempotent operations, single points of contention.
- Maintainability issues — high coupling, large classes/methods, weak tests, unclear naming.
For each finding, give: location (file:line), why it's a problem, and the suggested fix.
For .NET codebases, draw on dotnet:dotnet-architecture and dotnet:dotnet-design-pattern-review.
For security-relevant findings, apply security:security-owasp.
Phase 3 — Plan (approval gate)
Present a structured report:
- Clean architecture breakdown — how the system is structured and how it should be.
- Critical problem areas — the prioritized findings from Phase 2.
- Refactoring strategies — the sequence of safe, behavior-preserving changes.
- Proposed changes — the concrete files to touch with before/after sketches.
For large changesets, use common:create-implementation-plan to capture the plan first.
Wait for the user's approval before making any edit.
Phase 4 — Apply & verify
On approval, apply the improvements, then:
- Build the solution and run the test suite to confirm behavior is unchanged.
- If no build/test command is known, ask the user how to verify.
- Report what changed and the verification result.
Output Format
## Architecture Breakdown
<reconstructed structure + data flow>
## Critical Problem Areas
1. [Category] <finding> — file:line — <why> — <fix>
...
## Refactoring Strategies
<ordered, behavior-preserving steps>
## Proposed Changes
<files to touch + before/after sketches>
1---2name: senior-engineer-audit3description: Act as a senior engineer who just joined an unfamiliar codebase: reverse-engineer the architecture and complete data flow, then surface bad architecture decisions, duplicate logic, performance bottlenecks, scalability risks, and maintainability issues. Delivers a clean architecture breakdown, prioritized critical problem areas, refactoring strategies, and improved production-grade code. Use when the user asks to audit, review, or assess an entire codebase, understand an unfamiliar/inherited project, do a deep code review, find architectural or scalability problems, or "act like a senior engineer" auditing the code. For .NET-specific design-pattern review use dotnet:dotnet-design-pattern-review; for security-focused review use security:security-owasp.4---56# Senior Engineer Audit78Act like a senior engineer who just joined a massive, unfamiliar codebase. First reverse-engineer the9architecture and understand the complete data flow, then identify problems and propose concrete10improvements.1112## Critical Rules1314**ALWAYS:**15- Base every finding on the actual code read in THIS invocation — never assume structure from memory.16- Delegate the broad, read-heavy exploration to `Explore` subagents to keep the main context clean.17- Preserve observable functionality. This audit upgrades **code quality, scalability, and18 maintainability only** — it must not change product behavior.19- Present findings and a change plan, and get explicit user approval, BEFORE editing any code.2021**NEVER:**22- Make edits during the exploration or identification phases.23- Change public contracts, APIs, or behavior unless the user explicitly asks for it.24- Report a problem without a concrete file/location and an actionable recommendation.2526## Workflow2728### Phase 1 — Understand (read-only, delegated)2930Reverse-engineer the system before judging it. Launch `Explore` subagents **in parallel** (one message,31multiple calls) to map:3233- **Entry points & boundaries** — executables, APIs, jobs, UI roots, configuration.34- **Architecture & layers** — projects/modules, dependency direction, separation of concerns.35- **Complete data flow** — how a request/event travels from entry point through to persistence and back.36- **Cross-cutting concerns** — auth, logging, error handling, caching, configuration.37- **Conventions** — naming, patterns already in use, test layout.3839Summarize the reconstructed architecture and data flow before moving on.4041### Phase 2 — Identify4243Produce a prioritized findings list (highest impact first) across these categories:4445- **Bad architecture decisions** — wrong layering, leaky abstractions, misplaced responsibilities.46- **Duplicate logic** — repeated implementations that should be consolidated.47- **Performance bottlenecks** — N+1 queries, blocking calls, repeated expensive work, missing caching.48- **Scalability risks** — shared mutable state, non-idempotent operations, single points of contention.49- **Maintainability issues** — high coupling, large classes/methods, weak tests, unclear naming.5051For each finding, give: location (`file:line`), why it's a problem, and the suggested fix.5253For .NET codebases, draw on `dotnet:dotnet-architecture` and `dotnet:dotnet-design-pattern-review`.54For security-relevant findings, apply `security:security-owasp`.5556### Phase 3 — Plan (approval gate)5758Present a structured report:59601. **Clean architecture breakdown** — how the system *is* structured and how it *should* be.612. **Critical problem areas** — the prioritized findings from Phase 2.623. **Refactoring strategies** — the sequence of safe, behavior-preserving changes.634. **Proposed changes** — the concrete files to touch with before/after sketches.6465For large changesets, use `common:create-implementation-plan` to capture the plan first.66**Wait for the user's approval before making any edit.**6768### Phase 4 — Apply & verify6970On approval, apply the improvements, then:7172- Build the solution and run the test suite to confirm behavior is unchanged.73- If no build/test command is known, ask the user how to verify.74- Report what changed and the verification result.7576## Output Format7778```79## Architecture Breakdown80<reconstructed structure + data flow>8182## Critical Problem Areas831. [Category] <finding> — file:line — <why> — <fix>84...8586## Refactoring Strategies87<ordered, behavior-preserving steps>8889## Proposed Changes90<files to touch + before/after sketches>91```