Documentation Coverage
Metric: Percentage of patterns documented
Target: 80%+ of common patterns in PATTERNS.md
How to measure:
- Survey team: “Do you find the pattern you need in PATTERNS.md?”
- Track “Where do I document X?” questions in Slack
This guide covers everything you need to roll out Cortex TMS to a development team. You’ll learn how to onboard new team members, establish shared conventions, integrate TMS into your Git workflow, and maintain consistency as your team scales.
Traditional documentation approaches fail at scale because:
Cortex TMS solves this by creating a single source of truth that both humans and AI agents read.
Pilot Phase (1-2 weeks)
Core Team Adoption (2-4 weeks)
Full Rollout (4-6 weeks)
Maintenance (Ongoing)
This guide follows this roadmap step-by-step.
The first step is for a single person (usually the tech lead) to set up Cortex TMS and document existing conventions.
Install Cortex TMS
Initialize in the project
cd your-projectcortex-tms init --scope standardCreate a feature branch
git checkout -b docs/add-cortex-tmsThis is the most important step. You need to capture your team’s existing conventions.
Open docs/core/PATTERNS.md and document:
File organization:
## File Organizationsrc/ ├── components/ # React components (PascalCase.tsx) ├── hooks/ # Custom hooks (useSomething.ts) ├── services/ # API clients and business logic ├── utils/ # Pure functions (no side effects) └── types/ # TypeScript definitions
Naming conventions:
## Naming Conventions
- **React Components**: PascalCase (`UserProfile.tsx`)- **Hooks**: camelCase with "use" prefix (`useAuth.ts`)- **Services**: camelCase with "Service" suffix (`authService.ts`)- **Constants**: SCREAMING_SNAKE_CASE (`API_BASE_URL`)API patterns:
## API Client Pattern
**Canonical Example**: `src/services/apiClient.ts`
All API calls go through a centralized client:
```typescriptimport axios from 'axios';
const apiClient = axios.create({ baseURL: process.env.NEXT_PUBLIC_API_URL, timeout: 10000,});
// Add auth token to all requestsapiClient.interceptors.request.use((config) => { const token = localStorage.getItem('accessToken'); if (token) { config.headers.Authorization = `Bearer ${token}`; } return config;});<Aside type="tip" title="Pro Tip"> Don't invent new patterns during this phase. Document what the team already does, even if it's not perfect.</Aside></TabItem>
<TabItem label="Git Workflow">Open `CLAUDE.md` and document your Git workflow:
```markdown## 🛠 Git Workflow
**Branch Naming**:- `feature/` - New features- `fix/` - Bug fixes- `docs/` - Documentation changes- `refactor/` - Code refactoring
**Example**: `feature/user-authentication`
**Commit Messages**:Follow [Conventional Commits](https://www.conventionalcommits.org/):
- `feat: add user authentication`- `fix: resolve race condition in checkout`- `docs: update API documentation`- `refactor: extract validation logic`
**Pull Request Process**:1. Create feature branch from `main`2. Implement feature with tests3. Run `npm run lint && npm test`4. Push to remote5. Open PR with description (use template)6. Request review from 2+ team members7. Address feedback8. Squash merge to `main`Open CLAUDE.md and document your tech stack:
## 💻 Tech Stack
**Frontend**:- React 18 with TypeScript- Next.js 14 (App Router)- TailwindCSS for styling- React Query for data fetching- Zustand for state management
**Backend**:- Node.js 20- Express.js API- PostgreSQL database- Drizzle ORM- Redis for caching
**Testing**:- Jest (unit tests)- React Testing Library (component tests)- Playwright (e2e tests)
**Deployment**:- Frontend: Vercel- Backend: Railway- Database: SupabaseOpen .github/copilot-instructions.md and document critical rules:
## Critical Rules (Must Never Violate)
**Security**:- Never commit secrets (API keys, passwords, tokens)- Never use `eval()` or `dangerouslySetInnerHTML` without sanitization- Always validate user input (use Zod schemas)- Use HTTPS for all API calls in production
**Data Integrity**:- Never mutate state directly (use immutable updates)- Never use `any` type (use `unknown` if type is truly unknown)- Always handle loading and error states in components
**Performance**:- Never fetch data in loops- Always memoize expensive calculations (`useMemo`, `useCallback`)- Always lazy load large components (`React.lazy`)Document major architectural decisions that have already been made:
List past decisions
Examples:
Create ADR for each decision
touch docs/decisions/0001-use-nextjs-for-frontend.mdtouch docs/decisions/0002-use-postgresql-for-data-storage.mdtouch docs/decisions/0003-use-zustand-for-state-management.mdDocument the decision
Example 0001-use-nextjs-for-frontend.md:
# ADR-0001: Use Next.js for Frontend Framework
**Date**: 2026-01-15**Status**: Accepted**Deciders**: Tech Lead, Frontend Team
## Context
We need a React framework that supports:- Server-side rendering for SEO- Static site generation for marketing pages- API routes for backend-for-frontend pattern- File-based routing
## Decision
Use Next.js 14 with App Router.
## Rationale
- **SSR & SSG**: Built-in support (no extra config)- **Developer Experience**: Excellent tooling and documentation- **Performance**: Automatic code splitting, image optimization- **Ecosystem**: Large community, many examples- **Team Experience**: Team already knows React
## Consequences
**Positive**:- SEO-friendly pages out of the box- Fast initial load times- Reduced backend load (static pages served from CDN)
**Negative**:- Vendor lock-in to Vercel ecosystem- Learning curve for App Router (new paradigm)Run validation
cortex-tms validate --strictFix any issues reported.
Commit changes
git add .git commit -m "docs: add Cortex TMS documentation structure
- Initialize TMS with Standard scope- Document existing code patterns in PATTERNS.md- Create ADRs for major architectural decisions- Configure AI agent instructions (CLAUDE.md, copilot-instructions.md)
Co-Authored-By: Cortex TMS ([email protected])"Push and create PR
git push origin docs/add-cortex-tmsgh pr create --title "Add Cortex TMS documentation" --body "See commit message"Get team buy-in
Before merging, present the PR to the team:
Once the pilot PR is merged, onboard 2-3 senior developers.
Schedule a 1-hour onboarding session
Agenda:
CLAUDE.md and PATTERNS.mdShare onboarding checklist
## Cortex TMS Onboarding Checklist
- [ ] Read [Tiered Memory System](/concepts/tiered-memory/) concept- [ ] Read `CLAUDE.md` (AI workflow)- [ ] Read `docs/core/PATTERNS.md` (coding conventions)- [ ] Read recent ADRs in `docs/decisions/`- [ ] Install AI agent (Claude Code, Copilot, or Cursor)- [ ] Complete hands-on exercise (see below)
### Hands-On Exercise
**Task**: Implement a new API endpoint for creating a task
**Requirements**:1. Read `NEXT-TASKS.md` to find the task description2. Follow `docs/core/PATTERNS.md#api-endpoints` for the pattern3. Use AI agent to generate code4. Write tests following `docs/core/PATTERNS.md#testing`5. Run `cortex-tms validate` before submitting PR
**Expected Time**: 30-45 minutes
**Success Criteria**:- Code matches documented patterns- AI agent generated most of the code- Tests pass- Validation passesPair with each developer
Spend 30 minutes with each developer watching them:
NEXT-TASKS.mdFix confusion immediately. If they struggle, update the docs.
With 2-3 senior devs onboarded, hold a patterns review meeting.
Review PATTERNS.md together
Go section-by-section and ask:
Resolve disagreements
If developers disagree on a pattern (e.g., “Should we use interface or type?”):
Option A: Vote and Document
Option B: Create an ADR
Example:
## TypeScript: Interface vs Type
**Decision**: Prefer `interface` for object shapes, `type` for unions/intersections
**Rationale**:- Interfaces can be extended (better for public APIs)- Types are more flexible (better for complex logic)
**Exception**: Use `type` when you need computed properties:```typescripttype Keys = 'name' | 'age';type Person = { [K in Keys]: string };Update PATTERNS.md
Make changes collaboratively during the meeting.
Commit the updates
git add docs/core/PATTERNS.mdgit commit -m "docs: refine coding patterns based on team review"git pushOnce 2-3 senior devs are productive with TMS, roll out to the entire team.
Send announcement email
Subject: Introducing Cortex TMS - New Documentation System
Hey team,
We're rolling out Cortex TMS, a new documentation system that helpsAI agents (Claude Code, Copilot, Cursor) follow our coding conventions.
What this means for you:- AI agents will generate code matching our patterns (fewer corrections!)- New hires onboard faster (all conventions documented)- Less "how do we do X?" questions (check PATTERNS.md)
Action items:1. Read CLAUDE.md and PATTERNS.md (15 minutes)2. Set up your AI agent (see guide below)3. Complete the onboarding exercise (30 minutes)
Resources:- Onboarding Guide: [link]- Slack channel: #cortex-tms- Office hours: Tuesdays 2-3pm
Questions? Reply to this email or ask in #cortex-tms.
- [Your Name]Host office hours
Schedule recurring office hours (e.g., Tuesdays 2-3pm) for the first month.
Developers can drop in and ask:
Create Slack/Discord channel
Create a dedicated channel for TMS discussions:
Create self-service onboarding materials:
Create docs/onboarding/quick-start.md:
Welcome to the team! This guide will get you up to speed with our documentation system in 15 minutes.
Cortex TMS organizes our documentation so AI agents (Claude Code, Copilot, Cursor) can read and follow our conventions automatically.
Install an AI agent:
Open the project with your AI agent:
claude-code . # or `code .` for Copilot, `cursor .` for CursorAsk your AI: “What’s the current sprint goal?”
If it reads NEXT-TASKS.md and responds, you’re set up correctly!
Pick a task from NEXT-TASKS.md and implement it with your AI agent:
npm testcortex-tms validatefeat: add [feature]Record a 10-minute screen recording showing:
Opening the project (0:00-1:00)
Reading documentation (1:00-3:00)
Using AI agent (3:00-7:00)
Validation and commit (7:00-10:00)
cortex-tms validateUpload to YouTube (unlisted) or internal wiki.
Create a one-page cheat sheet (PDF or Notion page):
cortex-tms validate && npm test| File | Purpose | Read Frequency |
|---|---|---|
NEXT-TASKS.md | Current sprint tasks | Daily |
CLAUDE.md | AI workflow config | Once (onboarding) |
docs/core/PATTERNS.md | Coding conventions | As needed |
docs/decisions/ | ADRs | When making architecture changes |
# Validate documentation healthcortex-tms validate --strict
# Check project statuscortex-tms status
# Run testsnpm test
# Lint codenpm run lintClaude Code: Reads CLAUDE.md automatically
Copilot: Reads .github/copilot-instructions.md
Cursor: Reads .cursorrules (symlinked to CLAUDE.md)
AI not following patterns? → Check if pattern is in PATTERNS.md (if not, add it)
Validation failing?
→ Run cortex-tms validate --verbose for details
Don’t know where to document something? → Ask in #cortex-tms Slack channel
Integrate Cortex TMS into your PR review process.
Create .github/pull_request_template.md:
## Description
<!-- What does this PR do? Reference NEXT-TASKS.md if applicable -->
## Type of Change
- [ ] feat: New feature- [ ] fix: Bug fix- [ ] docs: Documentation update- [ ] refactor: Code refactoring- [ ] test: Test improvements- [ ] chore: Build/tooling changes
## Checklist
### Code Quality- [ ] Code follows patterns in `docs/core/PATTERNS.md`- [ ] Tests added/updated (unit + integration)- [ ] All tests pass (`npm test`)- [ ] Linting passes (`npm run lint`)- [ ] TypeScript compiles (`npm run type-check`)
### Documentation- [ ] `cortex-tms validate --strict` passes- [ ] Updated `docs/core/PATTERNS.md` if adding new patterns- [ ] Created ADR if making architectural decision- [ ] Updated `NEXT-TASKS.md` if completing tasks
### AI Agent Tested- [ ] Tested with Claude Code / Copilot / Cursor- [ ] AI agent can follow the new pattern (if applicable)
## Screenshots (if applicable)
<!-- Add screenshots for UI changes -->
## Related Issues
<!-- Link to GitHub issues: Closes #123 -->Update your code review guidelines to include TMS checks:
# Code Review Checklist
## Functional Review- [ ] Code solves the stated problem- [ ] Edge cases handled- [ ] Error handling appropriate
## Pattern Compliance- [ ] **Follows PATTERNS.md**: Check that code matches documented conventions- [ ] **Canonical examples**: If adding new patterns, include canonical example- [ ] **No hallucinated patterns**: Code doesn't introduce undocumented conventions
## Testing- [ ] Tests cover happy path and error cases- [ ] Test names are descriptive- [ ] Mocks are appropriate
## Documentation- [ ] **NEXT-TASKS.md updated**: Mark tasks complete if applicable- [ ] **PATTERNS.md updated**: Add new patterns if introduced- [ ] **ADR created**: If making architectural decision- [ ] **Validation passes**: `cortex-tms validate` succeeds
## Questions for Reviewer- Does this pattern make sense?- Should this be an ADR instead of a pattern?- Is the canonical example clear?Establish a weekly ritual for maintaining NEXT-TASKS.md:
Who: Tech lead or product manager
Steps:
Review backlog
Check FUTURE-ENHANCEMENTS.md for upcoming work.
Update NEXT-TASKS.md
Add new tasks for the week:
## Active Sprint: User Profile Feature (Week of Jan 20)
**Why this matters**: Users need to customize their profiles
**Sprint Goal**: Complete user profile CRUD operations
### Tasks
#### 1. Create Profile API Endpoints- [ ] GET /api/profile- [ ] PUT /api/profile- [ ] Tests for profile endpoints
#### 2. Build Profile UI- [ ] Profile form component- [ ] Avatar upload- [ ] Form validation
#### 3. Update Documentation- [ ] Add profile pattern to PATTERNS.md- [ ] Create ADR for avatar storage decisionCommunicate to team
Post in Slack:
“NEXT-TASKS.md updated with this week’s sprint. Check it out: [link]”
Who: Tech lead or team member on rotation
Steps:
Review completed tasks
Check which tasks in NEXT-TASKS.md are marked ✅ Done.
Create archive file
touch docs/archive/sprint-2026-01-20-user-profile.mdCopy completed tasks to archive
# Sprint: User Profile Feature (Jan 20-24, 2026)
**Goal**: Complete user profile CRUD operations
## Completed Tasks
### ✅ Create Profile API Endpoints- GET /api/profile- PUT /api/profile- Tests for profile endpoints
**Outcome**: All endpoints working. 15 tests passing.
### ✅ Build Profile UI- Profile form component- Avatar upload (S3 integration)- Form validation with Zod
**Outcome**: Profile page live in production.
## Metrics
- **Story Points**: 13- **Completed**: 13/13- **Blockers**: 1 (S3 permissions, resolved)
## Retrospective
**What went well**:- AI agents generated most boilerplate- Patterns in PATTERNS.md prevented inconsistencies
**What to improve**:- Avatar upload took longer than expected- Need to document S3 setup in TROUBLESHOOTING.mdClean up NEXT-TASKS.md
Remove completed tasks, keep only upcoming work.
Validate
cortex-tms validate --strictCommit
git add docs/archive/ NEXT-TASKS.mdgit commit -m "docs: archive sprint 2026-01-20 (user profile feature)"git pushWho: Entire team (30-minute meeting)
Steps:
Review PATTERNS.md
Go through each section and ask:
Update patterns
If the team agrees on a change, update PATTERNS.md immediately.
Create ADRs for major changes
If changing an established pattern (e.g., switching from REST to GraphQL):
Communicate changes
Post in Slack:
“PATTERNS.md updated: We’re now using Zod for all validation (see ADR-0015)”
Situation: Two developers disagree on whether to use interface or type for TypeScript definitions.
Resolution Process:
Discuss in Slack or PR comments
Each developer presents their reasoning.
Check existing codebase
Run a quick search to see what’s more common:
git grep "^interface " | wc -l # Count interfacesgit grep "^type " | wc -l # Count typesVote if needed
If no clear consensus, take a team vote.
Document the decision
Update PATTERNS.md with the decision and rationale:
## TypeScript: Interface vs Type
**Decision**: Prefer `interface` for object shapes
**Rationale**:- Existing codebase uses interfaces 70% of the time- Interfaces can be extended (better for public APIs)- Team voted 5-2 in favor
**Exception**: Use `type` for unions and intersectionsCommit and communicate
git commit -m "docs: document interface vs type preference"Post in Slack:
“PATTERNS.md updated: Use
interfacefor object shapes (see details in commit)“
Situation: A new mid-level developer joins the team.
Onboarding Plan:
Day 1: Read documentation (2 hours)
Assign the new hire to read:
CLAUDE.md (AI workflow)docs/core/PATTERNS.md (coding conventions)docs/decisions/Day 1: Pair with senior dev (2 hours)
Pair with a senior developer to:
Day 2: Small PR (4 hours)
Assign a small, well-defined task:
Senior dev reviews the PR with extra scrutiny on pattern compliance.
Day 3-5: Independent work with support (3 days)
Assign progressively larger tasks:
End of Week 1: Check-in
Ask:
Update documentation based on feedback.
Situation: GitHub Copilot suggests code that violates a documented pattern.
Root Cause Analysis:
Problem: The pattern isn’t in PATTERNS.md yet.
Solution:
PATTERNS.md## API Response Format
**Canonical Example**: `src/controllers/tasks.controller.ts`
All API responses use this format:
```typescript// Success{ status: 'success', data: { ... } }
// Error{ status: 'error', message: '...' }</TabItem>
<TabItem label="Cause 2: Pattern Is Buried">**Problem**: The pattern is documented but buried in a 600-line file.
**Solution**:
1. Move critical patterns to `.github/copilot-instructions.md`2. Reference detailed patterns from there
Example:
```markdown## API Response Format (Critical)
✅ **Always use**: `{ status, data }` or `{ status, message }`
See `docs/core/PATTERNS.md#api-responses` for full details.Problem: Old code violates the pattern, and AI learns from it.
Solution:
Short-term: Add negative examples to PATTERNS.md
❌ **Bad** (legacy code, do not replicate):```typescriptreturn { success: true, payload: data };✅ Good (new code):
return { status: 'success', data };Long-term: Refactor legacy code to match patterns
Create a backlog task:
“Refactor legacy API responses to match new pattern”
Track these metrics to measure TMS adoption success:
Documentation Coverage
Metric: Percentage of patterns documented
Target: 80%+ of common patterns in PATTERNS.md
How to measure:
Validation Pass Rate
Metric: Percentage of PRs where cortex-tms validate passes
Target: 95%+ pass on first try
How to measure:
AI Agent Adoption
Metric: Percentage of team using AI agents
Target: 80%+ of developers
How to measure:
Onboarding Time
Metric: Days to first PR for new hires
Target: under 3 days (down from ~7 days without TMS)
How to measure:
Code Consistency
Metric: Percentage of PRs requiring pattern corrections
Target: under 10% of PRs need pattern fixes
How to measure:
Documentation Freshness
Metric: Average age of patterns in PATTERNS.md
Target: No patterns older than 6 months without review
How to measure:
docs/core/PATTERNS.mdTeam Velocity
Metric: Story points completed per sprint
Target: Increase of 15-20% after TMS adoption
How to measure:
Knowledge Silos
Metric: Distribution of knowledge across team
Target: Any developer can work on any feature
How to measure:
Symptoms:
Solutions:
Make docs discoverable
Add a prominent link in the README:
## Documentation
- 📖 [Coding Patterns](docs/core/PATTERNS.md)- 🤖 [AI Workflow](CLAUDE.md)- 📋 [Current Sprint](NEXT-TASKS.md)Reference docs in PR template
Update .github/pull_request_template.md:
## Pattern Compliance
- [ ] Code follows [PATTERNS.md](docs/core/PATTERNS.md)- [ ] Checked with AI agent (Claude / Copilot / Cursor)Enforce in code review
Reviewers should comment:
“This doesn’t follow our auth pattern. See
docs/core/PATTERNS.md#authentication”
Gamify adoption
Track and celebrate:
Symptoms:
Solutions:
Schedule monthly pattern review
Add recurring meeting:
Make updates part of workflow
When a developer introduces a new pattern:
Use Git blame to find stale sections
git blame docs/core/PATTERNS.md | grep "2025-06"Flag sections not updated in 6+ months.
Deprecation process
When deprecating a pattern:
## Old Pattern (Deprecated)
⚠️ **Deprecated as of 2026-01-15**. Use [New Pattern](#new-pattern) instead.
[Old pattern details for reference]Remove after 3 months.
Start Small, Expand Gradually
Don’t document everything on day 1. Start with 5-10 critical patterns and add more as needed.
Make It a Team Effort
Don’t assign documentation to one person. Every developer should contribute to PATTERNS.md.
Review Patterns Monthly
Schedule a recurring meeting to review and update patterns. Documentation rots without maintenance.
Celebrate Wins
Share success stories: “AI generated 80% of this PR following our patterns!” This encourages adoption.
Listen to New Hires
New hires spot documentation gaps. When they ask questions, update the docs instead of just answering.
Enforce in CI/CD
Add cortex-tms validate to your CI pipeline. Fail PRs if validation doesn’t pass.
Now that you understand team adoption: