Day 03 Applied Practice

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 hour Hands-on Precision AI Academy

Today’s Objective

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.

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.

When to Use Composer vs Chat vs Cmd+K

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

Which Mode to Use
TEXT
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

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.

Weak vs Strong Composer Prompts
TEXT
# 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.

Build a Feature with Composer

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

Feature Build Prompt
TEXT
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.

60%

Supporting Resources

Go deeper with these references.

Cursor
Cursor Documentation Official Cursor IDE documentation covering features, keybindings, and configuration.
YouTube
Cursor AI Tutorials Community video tutorials demonstrating Cursor workflows in real projects.
GitHub
Awesome Cursor Rules Community-shared .cursorrules files for popular frameworks and languages.

Day 3 Checkpoint

Before moving on, make sure you can answer these without looking:

Continue To Day 4
Cursor Rules: Teach Cursor Your Codebase Standards