Feature Development Walkthrough with Cursor
This guide walks through the process of using Cursor's AI capabilities to add new features to a codebase while maintaining code quality, documentation, and existing functionality.
Overview
The key to successful AI-assisted feature development is proper planning and iterative refinement. This walkthrough emphasizes:
- Clear goal definition before writing code
- Design documentation that can be reviewed and refined
- Careful code review to prevent unexpected side effects
- Incremental testing and commits for maintainability
Quick Start Summary
TL;DR - The Essential Workflow:
- Branch - Create a feature branch
- Prompt - Send one comprehensive prompt with: goals + your design ideas + request for recommendations + request for design planning doc
- Review & Iterate - Review the design doc, identify issues, iterate until satisfied
- Finalize - Request final design spec + implementation plan (remove time estimates)
- Implement - Start implementation, but:
- Review every code change line-by-line (don't "Accept All")
- Watch for deleted code - may have side effects
- Test after each logical chunk
- Commit incrementally with clear messages
- Fix issues before moving forward
Golden Rule: You are the architect. The AI is your assistant, not your replacement.
0. Prepare Your Code Base
Create a Feature Branch
Before starting any development work:
Create a feature branch from your main/development branch:
git checkout -b feature/your-feature-nameOr ensure you're on your own dev branch if that's your workflow:
git checkout your-dev-branch
Why this matters: Working on a separate branch allows you to experiment freely, iterate on the design, and easily discard changes if needed without affecting the main codebase.
1. Prepare Your Initial Prompt
The quality of your initial prompt significantly impacts the quality of the AI's response. Include all of these elements in your first prompt:
1.1 Define Your Goals
Be specific about what you want to achieve:
Good example:
I need to add a feature that allows users to export their data in CSV format. The feature should:
- Support exporting all data or filtered subsets
- Handle large datasets without blocking the UI
- Include proper error handling for file system issues
- Be accessible from the main dashboard
Poor example:
Add CSV export functionality.
1.2 Communicate Your Existing Design
If you have architecture preferences or constraints, state them upfront:
Example:
Our application uses a layered architecture with:
- UI components in React
- Business logic in a service layer
- Data access through repository patterns
I'm thinking the export feature should:
- Add a new ExportService in the service layer
- Use background workers for large exports
- Store temporary files in our existing temp directory structure
1.3 Ask for Recommendations
Don't assume your initial design is optimal:
Example:
Before we proceed, are there any design patterns or approaches you'd recommend that would be a better fit for this use case? Consider:
- Performance implications
- Maintainability
- Integration with our existing architecture
- Industry best practices
1.4 Request a Design Planning Document
Explicitly ask for documentation before implementation:
Example:
Please create a design planning document that includes:
- High-level architecture
- Component/class structure
- Data flow
- Key design decisions and their rationale
- Potential challenges and mitigation strategies
- Dependencies on existing code
1.5 Submit the Prompt
Send all of the above in a single, comprehensive prompt to give the AI full context.
2. Review the Design Planning Document and Iterate
2.1 Carefully Review the Planning Document
The AI will generate a design document. Read it thoroughly and evaluate:
- Completeness: Does it cover all your requirements?
- Correctness: Does it align with your existing architecture?
- Clarity: Can you and your team understand the proposed approach?
- Feasibility: Are there any red flags or overly complex solutions?
2.2 Identify Issues and Concerns
Make notes on:
- Missing requirements or edge cases
- Design decisions you disagree with
- Unclear explanations
- Potential conflicts with existing code
- Security or performance concerns
2.3 Iterate Until Satisfied
Engage in a conversation with the AI to refine the design:
Example iteration:
The proposed design looks good, but I have a few concerns:
- The background worker approach might be overkill for our use case since most exports will be < 1000 rows
- I don't see how this integrates with our existing authentication/authorization system
- Can we simplify the temporary file management by using the existing FileService?
Please revise the design to address these points.
Continue iterating until you have a design you're confident in.
3. Finalize Design and Implementation Plan
3.1 Request Final Design Specification
Once you're satisfied with the design, ask for a final, polished version:
Example:
Please create a final design specification document that incorporates all the changes we've discussed. This should serve as the definitive reference for this feature.
3.2 Request Implementation Plan
Ask for a step-by-step implementation plan:
Example:
Now please create a detailed implementation plan that breaks down the development into logical steps. Include:
- The sequence of changes (e.g., models first, then services, then UI)
- Which files need to be created or modified
- Testing considerations at each step
- Any setup or configuration changes needed
3.3 Remove Time Estimates
⚠️ Important Note: The AI often provides implementation timelines measured in weeks. These estimates are typically very inaccurate and overly pessimistic.
Action: Review the implementation plan and remove any time estimates. Focus on the logical sequence of work instead.
4. Begin Implementation
4.1 Initiate the Implementation
Once the plan is finalized, start the implementation:
Example:
Let's begin implementing this feature following the plan. Please start with step 1 and update the implementation plan document as you complete each step.
4.2 Review Every Change
⚠️ Critical: Do NOT "Accept All" changes blindly.
For each file the AI modifies:
- Review line by line - Even if you trust the AI, understand what changed
- Pay special attention to deletions - Removed code may have unexpected side effects elsewhere
- Check for logic changes - Ensure modified code still handles all original cases
- Verify imports and dependencies - Make sure new dependencies are appropriate
Common issues to watch for:
- Removed error handling
- Deleted code that other parts of the system depend on
- Overly aggressive refactoring
- Changed behavior of existing functions
- Missing edge case handling
4.3 Test and Commit Iteratively
Don't wait until everything is done to test and commit. Instead:
Test Frequently
After each logical chunk of changes:
- Compile/build the project - Ensure no syntax errors
- Run existing tests - Verify nothing broke
- Manually test - Try the new and related existing features
- Fix issues immediately - Don't accumulate technical debt
Example conversation:
I've reviewed the changes to the service layer. Before we continue to the UI components, let me test this. [Test the changes] I found an issue: the export fails when the dataset is empty. Please add proper handling for empty datasets.
Commit Logically
Group related changes into coherent commits:
Good commit strategy:
- Commit 1: "Add data models for CSV export feature"
- Commit 2: "Implement ExportService with core export logic"
- Commit 3: "Add export API endpoints"
- Commit 4: "Create export UI components"
- Commit 5: "Add integration tests for export feature"
Poor commit strategy:
- Commit 1: "Add feature" (everything at once)
Benefits of incremental commits:
- Easier to review changes
- Simpler to identify which commit introduced a bug
- Can cherry-pick specific parts if needed
- Better project history
4.4 Handle Compilation and Runtime Issues
When issues arise:
Describe the error clearly to the AI:
The code doesn't compile. Error:
[paste full error message]
This is happening in [file name] at [location]Test the fix before continuing:
Thanks, that fixed the compilation error. Let me test the functionality... [test results]Don't move forward until the current step is working correctly
5. Final Steps
5.1 Comprehensive Testing
Before considering the feature complete:
- Run full test suite
- Test all new functionality
- Test existing functionality that might be affected
- Test edge cases and error conditions
- Consider having a colleague review
5.2 Documentation
Ensure you have:
- Updated README or user documentation
- Code comments for complex logic
- API documentation if applicable
- The design and implementation docs from steps 2-3
5.3 Create Pull Request
When ready:
- Push your feature branch
- Create a pull request with:
- Clear description of the feature
- Link to design documents
- Test results
- Screenshots/demos if applicable
Best Practices Summary
✅ Do:
- Start with clear, comprehensive prompts
- Iterate on design before implementation
- Review every code change carefully
- Test and commit incrementally
- Ask the AI to explain unclear changes
- Keep the AI focused on one task at a time
❌ Don't:
- Skip the design phase
- Accept all changes without review
- Let the AI remove code without understanding why
- Wait until the end to test
- Trust AI-generated time estimates
- Continue implementing if something isn't working
Troubleshooting Common Issues
The AI Removes Important Code
Problem: The AI deletes code that's needed elsewhere.
Solution:
- Tell the AI specifically: "You removed [code/function]. This is still needed because [reason]. Please restore it and modify your approach."
- Review the context - did the AI have visibility into all the places the code is used?
The AI Makes Too Many Changes at Once
Problem: The AI modifies dozens of files in one response.
Solution:
- "Let's slow down. Please only modify [specific subset] for now."
- "Let's break this into smaller steps. First, just handle [specific part]."
The Design Doesn't Match Your Architecture
Problem: The proposed design conflicts with your project's patterns.
Solution:
- Provide more context about your architecture
- Share relevant existing code examples
- Explicitly state constraints: "In our codebase, we always [pattern]. Please redesign using this approach."
You're Not Sure If a Change Is Correct
Problem: The AI made a change you don't fully understand.
Solution:
- Ask: "Can you explain why you changed [specific code] to [new version]?"
- Ask: "What are the implications of this change?"
- Ask: "Could this affect [related functionality]?"
Conclusion
AI-assisted development with Cursor is powerful, but requires thoughtful guidance and careful review. By following this structured approach, you can leverage AI to increase productivity while maintaining code quality and preventing regressions.
Remember: You are the architect and reviewer. The AI is your assistant, not your replacement.