Prompt
How do I build an app with AI help and still keep it maintainable?
Latest observation
To build an app with AI help and still keep it maintainable, treat AI as a coding assistant, not as the architect or source of truth.
Good approach
1. Design first, code second
Before asking AI to generate code, define:
- the app’s purpose
- main user flows
- data model
- tech stack
- folder structure
- API boundaries
If you can’t explain the feature clearly, AI will likely produce messy code.
2. Ask for small, focused pieces
Don’t ask for “build the whole app.”
Instead ask for:
- one component
- one API endpoint
- one validation function
- one migration
- one test file
Smaller outputs are easier to review, integrate, and maintain.
3. Use AI for scaffolding, not final authority
AI is great for:
- boilerplate
- repetitive code
- tests
- refactors
- documentation
- examples
But you should still own:
- architecture decisions
- naming
- state management patterns
- security decisions
- error handling strategy
4. Keep a strong structure
Use a predictable layout, for example:
src/componentssrc/featuressrc/servicessrc/utilssrc/tests
This makes it easier to know where AI-generated code belongs.
5. Standardize coding rules
Set rules early:
- formatter: Prettier, Black, gofmt, etc.
- linter: ESLint, Ruff, etc.
- type system: TypeScript, Python type hints, etc.
- naming conventions
- error handling patterns
Then ask AI to follow those rules every time.
6. Require tests for generated code
Whenever AI writes business logic, ask for:
- unit tests
- edge cases
- failure cases
This protects you from subtle bugs and makes refactoring safer.
7. Review AI output like code from a junior developer
Check for:
- duplication
- hidden assumptions
- incorrect dependencies
- security issues
- poor abstractions
- hardcoded values
If the code is hard to explain, it’s probably hard to maintain.
8. Avoid over-abstracting too early
AI often creates extra interfaces, classes, or helper layers.
Keep it simple unless there’s a real need for abstraction.
A maintainable app usually has:
- straightforward logic
- clear boundaries
- minimal indirection
9. Keep a human-written architecture doc
Maintain a short living document with:
- stack choice
- module responsibilities
- API conventions
- database schema notes
- common patterns
This reduces drift between AI-generated code and the intended design.
10. Use AI to improve existing code
A very maintainable workflow is:
- write a small feature manually
- ask AI to suggest cleanup
- compare alternatives
- keep the simplest good version
This usually produces better code than fully AI-generated implementation.
Practical workflow
A good loop looks like this:
- Define feature in plain English
- Ask AI for a plan, not code
- Review and adjust the plan
- Ask AI to generate one small part
- Run tests/linter
- Refactor manually if needed
- Commit in small chunks
Prompts that help
Try prompts like:
- “Design the folder structure for this app with maintainability in mind.”
- “Write a single React component that follows these conventions…”
- “Generate tests for this function, including edge cases.”
- “Refactor this code to reduce duplication without changing behavior.”
- “Explain the tradeoffs of these two implementations.”
Common mistakes to avoid
- letting AI generate entire projects blindly
- accepting code without understanding it
- not enforcing linting/formatting
- mixing styles from multiple AI outputs
- skipping tests
- overengineering because AI suggested it
Rule of thumb
If you want maintainability, optimize for:
- clarity
- small modules
- tests
- consistent conventions
- human ownership of architecture
If you want, I can also give you:
- a maintainable AI-assisted development workflow,
- a project structure template, or
- a prompting system for coding with AI.