Strategies and prompting
Overview
This section outlines a framework for using AI in software development, highlighting when to use structured workflows versus exploratory approaches. It also covers prompting patterns for feature planning, UI prototyping, and test generation, helping you choose the right strategy based on problem clarity and requirement maturity.
Strategies for AI-assisted development
This section presents two high-level strategies for AI-assisted development: test-driven development (TDD) with an outline strategy, and manual exploration. For task-specific workflows and prompt templates (feature planning, UI prototyping, test generation), see Prompting strategies.
Note: These strategies are not mutually exclusive. You can apply both in the same project.
Test-driven development and outline strategy
Use this strategy when the problem and solution are well defined, and you want AI to write implementations guided by tests. In this approach, you create tests first to define the expected outcome, then ask the AI agent to implement code that passes those tests.
When to use it
Best for: Problems with a clear path to resolution or understanding, solutions that you can break down into smaller chunks (functions, interfaces, or flows), and projects that require high test coverage.
How this strategy works
- Ask the AI agent to create tests based on your expected outcome. Confirm that the tests fail.
Note: Add an explicit rule in your prompt that you are using test-driven development to prevent the AI from creating mocks.
- Review the tests and refactor them if they do not match your needs.
- Commit the tests.
- Ask the AI agent to write code that makes the tests pass.
- Review and refactor the code as needed.
- Commit the changes.
Examples
- Configuration page — You are a React expert and ask AI to generate a configuration page with an input and a dropdown.
- CRUD endpoint — You are experienced in backend development and ask AI to create a generic CRUD endpoint.
Manual exploration strategy
Use this strategy when the problem is unclear or involves unfamiliar tools and you need to explore before moving into structured development. In this approach, you explore the problem manually before planning a solution and committing the results to reduce uncertainty. Once you establish clarity, you can provide the AI agent with more specific rules or prompts.
When to use it
Best for: Problems that involve uncertainty, unfamiliar tools, protocols, or behaviors, or projects that do not have a clear definition of success.
How this strategy works
We recommend using Plan Mode for this strategy if it is available in your agent.
- Ask the AI agent to read relevant information about the issue you want to resolve. Use non-coding modes to ensure it only gathers context.
- Create a plan with the AI agent to approach the issue.
- Verify that the AI agent does not make incorrect assumptions.
- Refine the plan before implementation. Refine the plan early to gain higher leverage, as improving the plan itself is more effective than revising generated code later.
- Ask the AI agent to implement the solution.
- Review and refactor the code as needed.
- Iterate the last two steps as required.
- Commit the changes.
Examples
- OAuth exploration — You need to learn how OAuth works, so you manually implement client IDs, secrets, tokens, and distinguish between authorization and authentication.
- Asynchronous workflow — You are handling a complex asynchronous workflow involving multiple systems. You first build a simple end-to-end thread manually, with AI support, and later introduce more automation.
Prompting strategies
Use the following prompting patterns to guide AI agents through planning, implementation, and refinement tasks.
Feature planning & implementation
Use this strategy to generate feature ideas and implementation plans from requirements or user stories.
When to use it
Best for: Known features, prototypes, learning frameworks, rapid iteration
Not ideal for: Complex business logic, security-sensitive features
How this strategy works
1. Ideation phase — Create a prompt to brainstorm approaches. Review available modes in your AI agent and select the mode that best fits the task. Prompt structure:
Example:
2. Implementation phase — Use the agent to create components and basic wiring. Prompt structure:
Example:
3. Refining phase — Refine, validate, and adapt AI outputs to fit your specific context and constraints. Implement changes incrementally, in small, reversible batches, while following Recommendations. Have experts review the outputs against product requirements and quality standards, then customize the suggestions to align with your business needs.
UI Prototyping
AI can generate UI code from screenshots or UI descriptions. Use this approach to quickly prototype single screens and convert designs into functional code.
When to use it
Best for: Single-screen prototypes, design-to-code conversion, rapid UI iteration, component generation.
Not ideal for: Complex app architectures, full application development, advanced interactions.
How this strategy works
1. Prepare the design - Make sure to:
- Capture a clear screenshot of the design.
- Ensure that all text is readable and colors are visible.
- Include any interactive states, such as hover and focus, in separate screenshots.
2. Generate a single screen with a prompt - Use the following prompt structure to generate code:
Example:
3. Review and iterate - Use the following prompt to refine components:
Test generation
AI can generate unit and integration tests from code or specifications. This helps developers save time and improve coverage, but results should be reviewed carefully to ensure accuracy and reliability.
When to use it
Best for: Unit tests, Simple integration tests, simple mocking.
Not ideal for: End-to-end tests and complex integration tests.
Unit testing
1. Define prompt requirements - Include the following in your prompt:
- Function signature - Provide the full function signature and a concise description of expected behavior, including input and output types.
- Happy-path scenarios - Request tests that validate normal or expected inputs and outputs.
- Edge cases and error conditions - Include boundary conditions, invalid inputs, and expected error handling.
2. Implement prompt structure - Use this template as a starting point:
Integration testing
1. Define prompt requirements - Include the following in your prompt:
- Components - Specify which components interact and their roles.
- External dependencies - Identify external services, APIs, or third-party SDKs to mock.
- Data flow and state management - Describe how data moves between components and how state should change.
- User workflows - Define end-to-end user scenarios to verify.
2. Implement prompt structure - Use the example below and replace the component names with your app’s exact identifiers: