8.1 Cursor .cursorrules Configuration

Source: Cursor Tips Collection + Builder.io Cursor Guide

# .cursorrules - Project root

## Project Context
This is a Python FastAPI application using:
- SQLAlchemy for ORM
- Pydantic for validation
- pytest for testing
- Poetry for dependency management

## Code Style
- Use type hints for all functions
- Follow PEP 8 style guide
- Maximum line length: 88 (Black formatter)
- Use docstrings for public functions

## Architecture Patterns
- Repository pattern for data access
- Service layer for business logic
- Dependency injection via FastAPI

## Testing Requirements
- Write tests first, then implementation
- Use pytest fixtures for setup
- Aim for 80%+ coverage

## Important Constraints
- Do not modify files I didn't ask about
- Preserve existing error handling patterns
- Use existing utility functions when available
Best Practices
  1. Scope context with @file, @folders, @git
  2. Use "Reference Open Editors" shortcut for relevant files
  3. Break features into 3-5 smaller tasks per chat
  4. Add "(Do not change anything I did not ask for)" to prevent unwanted modifications
  5. Reset conversation when context becomes confused

8.2 Claude Code Context Management

Source: Anthropic Context Engineering

# CLAUDE.md - Project instructions

## Project Overview
{Brief description of the project}

## File Structure
```
src/
├── api/        # FastAPI routes
├── services/   # Business logic
├── models/     # Pydantic models
└── utils/      # Helper functions
```

## Key Commands
- `make test` - Run tests
- `make lint` - Run linter
- `make build` - Build Docker image

## Database Conventions
- Use migrations for schema changes
- Never delete migrations
- Prefix table names with module name

## When Making Changes
1. Check existing patterns first
2. Update tests if behavior changes
3. Run linting before committing
Key Insight

Claude Code uses "just in time" context loading - write targeted queries and store results rather than loading entire datasets.