Courses Curriculum Cities Blog Enroll Now
Cursor IDE Mastery · Day 3 of 5 ~45 minutes

Day 3: Composer: Build Entire Features Across Files

Tab and Cmd+K work on single files. Composer works across your entire codebase — it can create new files, modify existing ones, and implement features end-to-end with one instruction.

1
Day 1
2
Day 2
3
Day 3
4
Day 4
5
Day 5
What You'll Build

A complete feature built with Composer: a user authentication system with login/logout endpoints, a session model, and middleware — all generated across multiple files from a single description.

1
Section 1 · 8 min

When to Use Composer vs Chat vs Cmd+K

Cursor has three AI interaction modes. Knowing which to use saves time and frustration.

textWhich Mode to Use
Tab Completion
  Use for: typing code (passive, always on)
  Good at: completing patterns, next edit prediction

Cmd+K (Inline Edit)
  Use for: modifying selected code
  Good at: targeted transformations (add error handling,
            refactor, add types, write tests for this function)

Chat (Cmd+L)
  Use for: questions, understanding, debugging
  Good at: explaining code, diagnosing bugs, getting advice

Composer (Cmd+Shift+I)
  Use for: multi-file feature implementation
  Good at: "build X feature," "add Y capability to the project"
  Think of it as: you describe the feature, Composer writes
                  the code across all necessary files
2
Section 2 · 12 min

Effective Composer Prompts

Composer works best when you give it: the goal, the relevant context, and the constraints. Vague prompts produce code you'll spend more time fixing than if you'd written it yourself.

textWeak vs Strong Composer Prompts
# Weak — too vague
"Add authentication"

# Strong — specific constraints and context
"Add JWT-based authentication to this FastAPI app.
Create:
- POST /auth/login: accepts email + password, returns JWT token
- POST /auth/logout: invalidates the token
- GET /auth/me: returns current user info (requires valid token)
- A User model in database.py with: id, email, hashed_password
- A verify_token dependency for protected routes

Use python-jose for JWT, passlib for password hashing.
Token expiry: 24 hours.
Don't modify existing endpoints."

The constraints ("don't modify existing endpoints") are as important as the requirements. Composer will try to help with everything it thinks is related — be explicit about boundaries.

3
Section 3 · 25 min

Build a Feature with Composer

Open Composer with Cmd+Shift+I. Use this prompt on the FastAPI project from earlier in the course:

textFeature Build Prompt
Add a user management system to this FastAPI app.

Create:
1. models.py: User model (id, email, hashed_password, created_at)
2. auth.py: password hashing with bcrypt, JWT token creation/verify
3. routes/users.py: POST /users (register), POST /auth/login,
   GET /users/me (protected)

Requirements:
- Use existing database.py for SQLAlchemy session
- Use python-jose for JWT, passlib[bcrypt] for passwords
- Return 409 if email already exists
- Don't change main.py (just tell me what to add to it)

Existing files: @main.py @database.py

Composer will generate a diff showing every file it wants to create or modify. Review each change before accepting. If a file looks wrong, you can edit the prompt and regenerate just that file.

Review everything. Composer produces working code surprisingly often — but "working" means "runs without errors," not "does exactly what you meant." Read every file it generates. This takes 10 minutes and prevents 2 hours of debugging later.

What You Learned Today

  • When to use each Cursor mode: Tab for typing, Cmd+K for modifying, Chat for questions, Composer for multi-file features
  • How to write specific Composer prompts that include goals, constraints, and boundaries
  • The Composer review workflow: diffs before applying, file-by-file acceptance
  • Why reviewing Composer output always takes less time than debugging code you didn't review
Your Challenge

Go Further on Your Own

  • Use Composer to add comprehensive test coverage to a feature you've built: 'Add pytest tests for all endpoints in routes/users.py. Mock the database. Test success and error cases.'
  • Give Composer a vague prompt deliberately and observe the output. Then rewrite the prompt with specific constraints and compare. How much does specificity matter?
  • Build a feature entirely with Composer, then code-review the output as if a colleague wrote it. Write down: what's good, what you'd change, what's wrong. This trains you to use Composer effectively.
Day 3 Complete

Nice work. Keep going.

Day 4 is ready when you are.

Continue to Day 4
Course Progress
60%

Want live instruction and hands-on projects? Join the AI bootcamp — 3 days, 5 cities.

Finished this lesson?