Public EcoRouter Knowledge · AI-generated content ·
What should I include in a project plan or spec before asking an AI to write code?
The question
What should I include in a project plan or spec before asking an AI to write code?
To get the best results from an AI, treat it like a highly skilled junior developer: provide clear instructions, context, and constraints. Before starting, ensure you have these elements in your plan:
1. The Core Objective
- The "What": Define exactly what the code should do.
- The "Why": Briefly explain the purpose. This helps the AI choose the best approach (e.g., optimization for speed vs. readability).
2. Technical Stack and Constraints
- Language & Frameworks: Specify the exact version if it matters (e.g., "Python 3.12," "React 18").
- Dependencies: List the libraries you prefer (e.g., "Use Pandas for data processing," or "No external libraries, only standard library").
- Environment: Is this for a browser, a server, an AWS Lambda function, or a local script?
3. Functional Requirements
- Input/Output: Define what data goes in and what should come out. Include examples of expected formats (e.g., "Input: CSV file; Output: JSON object").
- Edge Cases: What should happen if the input is empty, malformed, or unexpectedly large?
- State/Logic: Describe the "happy path" (the ideal scenario) and any logical branching required.
4. Style and Quality Standards
- Formatting: Do you have specific style preferences? (e.g., "Follow PEP 8," "Use functional programming style," or "Strictly typed with TypeScript").
- Documentation: State clearly if you need code comments, type hints, or a separate README file.
- Testing: If you want unit tests, ask for them specifically (e.g., "Include PyTest unit tests covering the core logic").
5. Scope Boundaries
- "In Scope" vs. "Out of Scope": Be clear about what you don’t want the AI to handle. This prevents "code bloat" and keeps the output focused.
Example Template
If you are preparing a prompt, you can use this structure:
Role: You are an expert [Language] developer. Context: I am building [Project/Feature]. Task: Write a script that [Action]. Input: [Format]. Output: [Format]. Constraints:
- Use [Library/Version].
- Include error handling for [Specific Scenario].
- Keep the code modular and well-commented.
- Do not include [Feature X].
Pro-tip: If the project is large, break it into smaller modules. Asking for a complete, complex application in one go often leads to lower-quality code. Ask for the core logic first, then build the supporting features step-by-step.
Answering this used an estimated 90% less than EcoRouter’s configured frontier baseline
- Routed to
- Efficient
- Tokens
- 223 in / 625 out
- Cost
- $0.0010
- Baseline
- $0.01
Figures recorded by EcoRouter when this answer was generated, and fixed at that moment. Cost comparisons are against a configured reference model, not a measurement of electricity, carbon or water.
Ask about this
Ask EcoRouter a follow-up using this Knowledge as context. Nothing becomes public unless you choose to publish it.
Ask a follow-upComments
No comments yet.