Project Context
The project-context.md file is your projectâs implementation guide for AI agents. Similar to a âconstitutionâ in other development systems, it captures the rules, patterns, and preferences that ensure consistent code generation across all workflows.
What It Does
Section titled âWhat It DoesâAI agents make implementation decisions constantly â which patterns to follow, how to structure code, what conventions to use. Without clear guidance, they may:
- Follow generic best practices that donât match your codebase
- Make inconsistent decisions across different stories
- Miss project-specific requirements or constraints
The project-context.md file solves this by documenting what agents need to know in a concise, LLM-optimized format.
How It Works
Section titled âHow It WorksâEvery implementation workflow automatically loads project-context.md if it exists. The architect workflow also loads it to respect your technical preferences when designing the architecture.
Loaded by these workflows:
create-architectureâ respects technical preferences during solutioningcreate-storyâ informs story creation with project patternsdev-storyâ guides implementation decisionscode-reviewâ validates against project standardsquick-devâ applies patterns when implementing tech-specssprint-planning,retrospective,correct-courseâ provides project-wide context
When to Create It
Section titled âWhen to Create ItâThe project-context.md file is useful at any stage of a project:
| Scenario | When to Create | Purpose |
|---|---|---|
| New project, before architecture | Manually, before create-architecture | Document your technical preferences so the architect respects them |
| New project, after architecture | Via generate-project-context or manually | Capture architecture decisions for implementation agents |
| Existing project | Via generate-project-context | Discover existing patterns so agents follow established conventions |
| Quick Flow project | Before or during quick-dev | Ensure quick implementation respects your patterns |
What Goes In It
Section titled âWhat Goes In ItâThe file has two main sections:
Technology Stack & Versions
Section titled âTechnology Stack & VersionsâDocuments the frameworks, languages, and tools your project uses with specific versions:
## Technology Stack & Versions
- Node.js 20.x, TypeScript 5.3, React 18.2- State: Zustand (not Redux)- Testing: Vitest, Playwright, MSW- Styling: Tailwind CSS with custom design tokensCritical Implementation Rules
Section titled âCritical Implementation RulesâDocuments patterns and conventions that agents might otherwise miss:
## Critical Implementation Rules
**TypeScript Configuration:**- Strict mode enabled â no `any` types without explicit approval- Use `interface` for public APIs, `type` for unions/intersections
**Code Organization:**- Components in `/src/components/` with co-located `.test.tsx`- Utilities in `/src/lib/` for reusable pure functions- API calls use the `apiClient` singleton â never fetch directly
**Testing Patterns:**- Unit tests focus on business logic, not implementation details- Integration tests use MSW to mock API responses- E2E tests cover critical user journeys only
**Framework-Specific:**- All async operations use the `handleError` wrapper for consistent error handling- Feature flags accessed via `featureFlag()` from `@/lib/flags`- New routes follow the file-based routing pattern in `/src/app/`Focus on whatâs unobvious â things agents might not infer from reading code snippets. Donât document standard practices that apply universally.
Creating the File
Section titled âCreating the FileâYou have three options:
Manual Creation
Section titled âManual CreationâCreate the file at _bmad-output/project-context.md and add your rules:
# In your project rootmkdir -p _bmad-outputtouch _bmad-output/project-context.mdEdit it with your technology stack and implementation rules. The architect and implementation workflows will automatically find and load it.
Generate After Architecture
Section titled âGenerate After ArchitectureâRun the generate-project-context workflow after completing your architecture:
/bmad-bmm-generate-project-contextThis scans your architecture document and project files to generate a context file capturing the decisions made.
Generate for Existing Projects
Section titled âGenerate for Existing ProjectsâFor existing projects, run generate-project-context to discover existing patterns:
/bmad-bmm-generate-project-contextThe workflow analyzes your codebase to identify conventions, then generates a context file you can review and refine.
Why It Matters
Section titled âWhy It MattersâWithout project-context.md, agents make assumptions that may not match your project:
| Without Context | With Context |
|---|---|
| Uses generic patterns | Follows your established conventions |
| Inconsistent style across stories | Consistent implementation |
| May miss project-specific constraints | Respects all technical requirements |
| Each agent decides independently | All agents align with same rules |
This is especially important for:
- Quick Flow â skips PRD and architecture, so context file fills the gap
- Team projects â ensures all agents follow the same standards
- Existing projects â prevents breaking established patterns
Editing and Updating
Section titled âEditing and UpdatingâThe project-context.md file is a living document. Update it when:
- Architecture decisions change
- New conventions are established
- Patterns evolve during implementation
- You identify gaps from agent behavior
You can edit it manually at any time, or re-run generate-project-context to update it after significant changes.