AI Coding Agent Codebase Audit & Modernization
A structured audit prompt designed for AI coding agents to evaluate an unfamiliar codebase, identify security anti-patterns, spot performance bottlenecks, and generate prioritized action plans.
Customize & Generate Your Prompt
Adjust the variables below. Your customized prompt updates live in real-time ready to copy with zero setup.
You are performing an exhaustive technical audit of an existing codebase. ### Codebase Context - **Tech Stack**: Next.js 16 (App Router), TypeScript, Tailwind CSS, Prisma, PostgreSQL on Supabase, Upstash Redis - **Primary Audit Priority**: Security Vulnerabilities & Input Validation (OWASP) - **Known Constraints or Non-Negotiable Boundaries**: - Must preserve existing public API contracts and response schemas. - Must not introduce new heavy runtime dependencies. - Must maintain backward compatibility for existing active database rows. ### Audit Directives Analyze the provided architectural files, configuration, and patterns according to this 4-phase framework: 1. **Security & Vulnerability Assessment**: - Check for client-side secret exposure, unvalidated inputs, SQL/NoSQL injection risks, SSRF, and unauthenticated endpoints. - Evaluate authentication boundaries, session handling, and CORS policies. 2. **Performance & Resource Utilization**: - Identify blocking network requests, large bundle culprits, N+1 database queries, and memory leak hazards. - Recommend targeted optimizations (caching, query optimization, asset lazy-loading). 3. **Architecture & Code Maintainability**: - Assess modularity, circular dependencies, type strictness, and error-handling consistency. - Identify legacy patterns that should be deprecated. 4. **Actionable Remediation Matrix**: - Deliver a prioritized Markdown table with columns: [Issue, Severity (Critical/High/Medium/Low), Effort (S/M/L), Recommended Fix]. - Provide code snippets showing before and after implementations for the top 2 highest-impact findings.
How to Use This Prompt Effectively
- 1Enter your tech stack details and choose your primary audit priority.
- 2Add any constraints such as uptime requirements or database preservation rules.
- 3Feed the prompt to your AI model alongside your repository outline or key route handlers for a comprehensive health audit.
Representative AI Output
Sample output produced when using frontier AI models with the default parameters:
### Prioritized Audit Remediation Matrix | Issue | Severity | Effort | Recommended Fix | | :--- | :--- | :--- | :--- | | Unsanitized search params in SQL query | **Critical** | S | Replace raw template string with parameterized query | | Unbounded in-memory rate limiter | **High** | M | Migrate to atomic Redis sliding window counters | | Uncompressed dynamic images | **Medium** | S | Route through Next.js Image optimization pipeline |
Pro Optimization & Edge-Case Tips
- Run this prompt with your `package.json`, database schemas, and main API route files for the most accurate findings.
- Use the resulting remediation matrix directly in GitHub Issues or Linear tasks for phased team sprints.
- Combine this with automated linting and static analysis tools like ESLint and SonarQube for continuous coverage.
Related Tools on SPAUL Hub
More in Developers & Coding
View CategoryNext.js App Router Project Rules & AI Coding Agent Instructions
A comprehensive system prompt that transforms AI coding assistants (Claude 3.7, Cursor, ChatGPT, Gemini) into disciplined Next.js App Router architects. Prevents common hydration traps and enforce strict separation between Server and Client Components.
Supabase Edge Function Debugging & Security Review Prompt
Diagnose runtime errors, CORS header issues, environment variable leakage, and authentication token validation bugs in Supabase Deno Edge Functions.
React Component Refactoring & Unit Test Generation Prompt
Turn bloated, legacy React components with tangled state into modular, accessible, and high-performance components backed by a production-ready test suite.