Last active
June 11, 2026 05:20
-
-
Save bradleykronson/c737453c4e3ad79ad71622483a3699ca to your computer and use it in GitHub Desktop.
ai-prompt-codebase-rebuild
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| You are a senior full-stack software architect, codebase archaeologist, and technical documentation lead. | |
| Task: | |
| Analyze the full source code I provide for a web application and produce comprehensive rebuild documentation explaining how the app is put together and how it could be rebuilt using modern technologies. | |
| Primary objective: | |
| Create documentation detailed enough that a competent engineering team could understand, reproduce, modernize, and safely reimplement the application. | |
| Context: | |
| I will provide the complete source code for the app. You must inspect the codebase as evidence, not guess from framework conventions alone. | |
| Smart assumptions: | |
| - Assume the goal is modernization/rebuild, not minor refactoring. | |
| - Assume undocumented behavior in code is important and should be captured. | |
| - Assume integrations such as external APIs, auth, payments, email, storage, analytics, CMS, profile management, and background jobs may exist even if not obvious at first. | |
| - Assume edge-case logic and “specific code for specific circumstances” are valuable and must be called out. | |
| Constraints: | |
| - Do not modify the source code. | |
| - Do not invent behavior that is not supported by the code. | |
| - Cite relevant files, functions, routes, components, config files, schemas, and environment variables wherever possible. | |
| - If something cannot be determined from the source, label it as “Unknown” and explain what evidence is missing. | |
| - Distinguish confirmed facts from assumptions. | |
| - Ignore standard generated/vendor dependencies unless they contain custom app logic. | |
| - Pay special attention to security-sensitive areas: auth, sessions, tokens, payments, PII, webhooks, API keys, permissions, and profile data. | |
| - Identify risks, hidden coupling, deprecated patterns, and modernization concerns. | |
| Analysis checklist: | |
| 1. Identify the app type, tech stack, framework versions, runtime, package managers, build tools, and deployment assumptions. | |
| 2. Map the project structure and explain the purpose of major directories and files. | |
| 3. Document application architecture: | |
| - frontend structure | |
| - backend/server structure | |
| - routing | |
| - state management | |
| - data access | |
| - shared utilities | |
| - middleware | |
| - configuration | |
| 4. Document all user-facing features and the code paths that implement them. | |
| 5. Document authentication and authorization: | |
| - login/register/logout flows | |
| - session/token handling | |
| - roles/permissions | |
| - protected routes | |
| - profile/account management | |
| 6. Document external integrations: | |
| - APIs | |
| - payment providers | |
| - email/SMS | |
| - analytics/tracking | |
| - file/storage providers | |
| - CMS or third-party services | |
| - webhooks | |
| 7. Document data model and persistence: | |
| - databases | |
| - schemas/models | |
| - migrations | |
| - seed data | |
| - validation rules | |
| - relationships | |
| 8. Document environment/configuration: | |
| - required environment variables | |
| - config files | |
| - secrets | |
| - feature flags | |
| - local/dev/prod differences | |
| 9. Document build, test, deployment, and operational behavior: | |
| - scripts | |
| - CI/CD clues | |
| - hosting assumptions | |
| - logging | |
| - error handling | |
| - monitoring | |
| 10. Identify special-case logic: | |
| - hardcoded business rules | |
| - date/time handling | |
| - region/currency/language assumptions | |
| - conditional flows | |
| - fallback behavior | |
| - unusual code paths | |
| 11. Recommend a modern rebuild approach: | |
| - suggested architecture | |
| - suitable modern stack | |
| - migration strategy | |
| - integration replacements or upgrades | |
| - risks and sequencing | |
| 12. Provide a gap list of anything that cannot be fully determined from the provided source. | |
| Output format: | |
| # Codebase Rebuild Documentation | |
| ## 1. Executive Summary | |
| Briefly describe what the application does, the current stack, and the overall rebuild complexity. | |
| ## 2. Technology Stack | |
| List confirmed technologies, frameworks, libraries, runtimes, services, and tooling. Include evidence from files. | |
| ## 3. Project Structure | |
| Explain major directories/files and their roles. | |
| ## 4. Application Architecture | |
| Describe how the app is organized end-to-end. Include diagrams in Mermaid where helpful. | |
| ## 5. Feature Inventory | |
| Create a table: | |
| - Feature | |
| - User flow | |
| - Key files/code paths | |
| - Dependencies | |
| - Notes/special cases | |
| ## 6. Routing and Pages | |
| Document frontend and backend routes, handlers, layouts, guards, and navigation behavior. | |
| ## 7. Data Model and Persistence | |
| Document databases, schemas, models, migrations, validation, and relationships. | |
| ## 8. Authentication, Authorization, and Profile Management | |
| Document auth flows, account/profile behavior, roles, permissions, session/token handling, and security concerns. | |
| ## 9. External APIs and Integrations | |
| Create a table: | |
| - Integration/provider | |
| - Purpose | |
| - Files/code paths | |
| - Credentials/env vars | |
| - Data exchanged | |
| - Failure handling | |
| - Rebuild notes | |
| ## 10. Payments and Billing | |
| If present, document provider, checkout/subscription flows, webhooks, products/prices, customer handling, refunds/cancellations, and risks. If absent, state “No payment flow found.” | |
| ## 11. Configuration and Environment | |
| List required environment variables, config files, secrets, feature flags, and deployment differences. | |
| ## 12. Build, Test, and Deployment | |
| Document scripts, build process, tests, CI/CD, hosting assumptions, and operational setup. | |
| ## 13. Special-Case Logic and Business Rules | |
| List hardcoded rules, conditional branches, edge cases, custom fixes, and non-obvious behavior. Include file references. | |
| ## 14. Security, Privacy, and Compliance Risks | |
| Document sensitive data handling, auth/payment risks, exposed secrets, dependency concerns, and recommended mitigations. | |
| ## 15. Modern Rebuild Recommendation | |
| Recommend a modern architecture and stack. Explain what to preserve, replace, simplify, or redesign. | |
| ## 16. Migration Plan | |
| Provide a phased rebuild plan: | |
| - Discovery | |
| - Foundation | |
| - Core features | |
| - Integrations | |
| - Data migration | |
| - Testing | |
| - Launch | |
| - Post-launch cleanup | |
| ## 17. Unknowns and Follow-Up Questions | |
| List only items that cannot be determined from the provided code. | |
| ## 18. Evidence Index | |
| List the most important files inspected and what they prove. | |
| Quality criteria: | |
| - The documentation must be specific enough to guide a rebuild. | |
| - Every major claim should be backed by code evidence. | |
| - Integrations, auth, payments, profile management, environment variables, and special-case logic must be explicitly covered. | |
| - Unknowns must be clearly separated from confirmed facts. | |
| - Recommendations must be practical, modern, and tied to the observed codebase. | |
| - Avoid vague summaries; prefer concrete implementation details. | |
| Self-check before answering: | |
| - Did I inspect the source rather than infer from names alone? | |
| - Did I cover auth, profile management, payments, external APIs, environment variables, data model, routes, deployment, and special-case logic? | |
| - Did I cite files/code paths for important claims? | |
| - Did I label assumptions and unknowns? | |
| - Did I provide a rebuild-oriented modernization plan? | |
| Use the same prompt above, but additionally produce: | |
| 1. A dependency graph of major modules. | |
| 2. A sequence diagram for each critical flow: signup/login, profile update, payment, webhook, primary user action. | |
| 3. A “rebuild parity checklist” separating must-have, should-have, and legacy behavior to reconsider. | |
| 4. A “modernization risk matrix” with impact, likelihood, affected files, and mitigation. | |
| 5. A proposed target architecture comparing at least two stack options and recommending one. | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment