Claude Code
Best for: Autonomous workflows, complex refactoring, architectural decisions
Reads: CLAUDE.md automatically
Strength: Deep context understanding, follows multi-step workflows
This guide covers everything you need to know about integrating AI coding agents with Cortex TMS. You’ll learn how to configure Claude Code, GitHub Copilot, and Cursor to read your documentation, follow your patterns, and work autonomously within your established conventions.
Modern AI coding agents are powerful but suffer from a critical problem: they don’t know your project’s conventions unless you tell them explicitly.
Developer: "Add authentication to the API"
AI Agent: "Sure! I'll use HS256 JWT tokens stored in localStorage"
Developer: "No, we use RS256 with httpOnly cookies"
AI Agent: "Got it! Let me update..."
Developer: "Also, tokens expire in 1 hour, not 24 hours"
AI Agent: "Updating..."
Developer: "And follow the error handling pattern from the last PR"
AI Agent: "Which PR? Can you share the pattern?"
Developer: 😩Problem: Developers spend more time correcting AI than writing code themselves.
Developer: "Add authentication to the API"
AI Agent: [Reads NEXT-TASKS.md → sees "Implement auth"] [Reads docs/core/PATTERNS.md#authentication] [Generates code with RS256, httpOnly cookies, 15-min expiry]
Developer: "Perfect! Ship it."Solution: AI agents read your documented conventions and generate correct code the first time.
Cortex TMS integrates with three major AI coding agents:
Claude Code
Best for: Autonomous workflows, complex refactoring, architectural decisions
Reads: CLAUDE.md automatically
Strength: Deep context understanding, follows multi-step workflows
GitHub Copilot
Best for: Inline suggestions, rapid autocomplete, incremental coding
Reads: .github/copilot-instructions.md
Strength: Fast suggestions, integrates with VS Code/JetBrains
Cursor
Best for: Chat-based development, multi-file edits, codebase exploration
Reads: .cursorrules
Strength: Excellent chat interface, fast multi-file edits
Claude Code is Anthropic’s official CLI for autonomous AI coding. It reads CLAUDE.md automatically and follows your documented workflows.
Install Claude Code
# macOSbrew install anthropics/claude/claude-code
# Linux/Windows (download from website)# Visit: https://claude.ai/claude-codeAuthenticate
claude-code authFollow the browser authentication flow.
Verify installation
claude-code --versionCortex TMS generates CLAUDE.md with this structure:
# 🤖 Agent Workflow & Persona
## 🎯 Role
Expert Senior Developer. Follow the **"Propose, Justify, Recommend"** framework.
## 💻 CLI Commands
- **Test**: `npm test` or `pnpm test`- **Lint**: `npm run lint`- **Build**: `npm run build`
## 🛠 Operational Loop
**Step 0: Git Protocol (MANDATORY)**- Before ANY code changes: Create a branch using `git checkout -b type/ID-description`- NEVER work directly on `main` branch
**Implementation Steps:**1. Read `NEXT-TASKS.md` to understand the current objective.2. Cross-reference `docs/core/PATTERNS.md` for existing code conventions.3. If unsure of a term, check `docs/core/GLOSSARY.md`.4. Execute TDD (Test-Driven Development).
## 🧹 Post-Task Protocol
After completing a task:1. **Archive Completed Tasks**: Move done items from `NEXT-TASKS.md` to `docs/archive/`2. **Run Validation**: Execute `cortex-tms validate --strict`3. **Commit Changes**: Follow conventional commit formatKey sections:
Open CLAUDE.md and customize these sections:
## 🎯 Role
Expert TypeScript Developer specializing in React and Node.js APIs.
**Persona Traits**:- Prioritize type safety (prefer strict TypeScript)- Write testable code (dependency injection, pure functions)- Follow functional programming principles where appropriate- Question unclear requirements before implementing
**Communication Style**:- Ask clarifying questions when acceptance criteria are vague- Suggest improvements to patterns when you spot issues- Explain trade-offs when multiple approaches exist## 💻 CLI Commands
**Development**:- `npm run dev` - Start dev server on http://localhost:3000- `npm run dev:debug` - Start with Node debugger on port 9229
**Testing**:- `npm test` - Run Jest tests with coverage- `npm run test:watch` - Run tests in watch mode- `npm run test:e2e` - Run Playwright e2e tests
**Quality Checks**:- `npm run lint` - ESLint with autofix- `npm run type-check` - TypeScript compiler (no emit)- `npm run format` - Prettier formatting
**Database**:- `npm run db:migrate` - Run pending migrations- `npm run db:seed` - Seed development data- `npm run db:studio` - Open Drizzle Studio
**Build & Deploy**:- `npm run build` - Production build (outputs to dist/)- `npm run preview` - Preview production build locally## 🛠 Operational Loop
**Step 0: Git Protocol (MANDATORY)**
Before ANY code changes:1. Create a feature branch: `git checkout -b feature/task-name`2. NEVER work directly on `main` branch3. Branch naming convention: - `feature/` - New features - `fix/` - Bug fixes - `docs/` - Documentation changes - `refactor/` - Code refactoring
**After completing work**:1. Run all quality checks (lint, type-check, test)2. Commit with conventional format: - `feat: add user authentication` - `fix: resolve race condition in task sync` - `docs: update API documentation`3. Push to remote: `git push origin feature/task-name`4. Open PR with template (see .github/pull_request_template.md)## 🛠 Operational Loop
**Implementation Steps**:
1. **Understand the Task** - Read `NEXT-TASKS.md` to understand the current objective - Check for blockers or dependencies - If unclear, ask for clarification before proceeding
2. **Check Existing Patterns** - Read `docs/core/PATTERNS.md` for coding conventions - Reference canonical examples (e.g., `src/services/tasks.service.ts`) - Check `docs/core/GLOSSARY.md` for domain terminology
3. **Review Related ADRs** - Check `docs/decisions/` for relevant architectural decisions - If adding new architecture, create an ADR
4. **Test-Driven Development** - Write failing test first - Implement minimal code to pass - Refactor for clarity - Run full test suite: `npm test`
5. **Document as You Go** - Update `docs/core/PATTERNS.md` if introducing new patterns - Add inline comments for complex logic - Update API docs if changing interfacesOpen your project with Claude Code
cd your-projectclaude-code .Test: Reading NEXT-TASKS.md
Ask Claude:
“What’s the current sprint goal?”
Expected behavior:
NEXT-TASKS.mdTest: Following Patterns
Ask Claude:
“Implement the authentication middleware from the current sprint”
Expected behavior:
NEXT-TASKS.md to find the taskdocs/core/PATTERNS.md#authentication for the patternTest: Git Workflow
Ask Claude:
“Start working on the database setup task”
Expected behavior:
git checkout -b feature/database-setupTest: Post-Task Protocol
After implementing a feature, ask:
“I’m done with this task. What’s next?”
Expected behavior:
cortex-tms validateNEXT-TASKS.md to mark task completeYou can configure Claude to work alongside other AI agents:
## 🤝 Multi-Agent Workflow
**When working with GitHub Copilot**:- Copilot handles inline autocomplete (micro-level)- Claude handles feature implementation (macro-level)- Copilot reads `.github/copilot-instructions.md` for critical rules- Claude reads full context from `CLAUDE.md` and `docs/core/`
**Division of Labor**:- **Copilot**: Variable names, function signatures, repetitive code- **Claude**: Architecture decisions, test generation, refactoring
**Communication Protocol**:- Copilot suggestions must follow patterns in `docs/core/PATTERNS.md`- If Copilot suggests code that violates patterns, reject it- Claude has final authority on architecture (defers to ADRs)GitHub Copilot reads .github/copilot-instructions.md to understand project conventions. Cortex TMS generates this file with a reference to CLAUDE.md.
Install GitHub Copilot
Verify installation
Open VS Code → Settings → Search “Copilot” → Ensure enabled
Check Copilot reads instructions
Open any .ts file and type a comment:
// Generate a function thatCopilot should suggest completions based on your project context.
Cortex TMS generates .github/copilot-instructions.md with this default content:
# GitHub Copilot Instructions for [Project Name]
See `CLAUDE.md` for full project conventions and workflows.
## Critical Rules (Security & Correctness)
- **Never commit secrets**: No API keys, passwords, or tokens in source code- **Authentication**: Use RS256 JWT tokens with httpOnly cookies (see `docs/core/PATTERNS.md#authentication`)- **Error Handling**: Always use AppError class (see `docs/core/PATTERNS.md#error-handling`)
## Tech Stack
- **Language**: TypeScript (strict mode)- **Framework**: Express.js- **Database**: PostgreSQL with Drizzle ORM- **Testing**: Jest (unit), Playwright (e2e)
## Quick Reference
- Coding patterns: `docs/core/PATTERNS.md`- Architectural decisions: `docs/decisions/`- Current sprint: `NEXT-TASKS.md`Key sections:
Edit .github/copilot-instructions.md to add project-specific rules:
## Critical Rules (Security & Correctness)
**Authentication & Authorization**:- Never use HS256 for JWT tokens → Use RS256 (asymmetric)- Never store tokens in localStorage → Use httpOnly cookies- Access tokens expire in 15 minutes- Refresh tokens expire in 7 days- Always validate token signature server-side
**Data Validation**:- Validate all user input with Zod schemas- Sanitize SQL inputs (Drizzle handles this automatically)- Never trust client-provided data
**Secrets Management**:- Never commit secrets to Git (check .gitignore)- Use environment variables for all secrets- Never log secrets (even in debug mode)
**Financial Data**:- Use `Decimal` type for money (never `number`)- Store cents as integers (avoid floating-point errors)- Round currency to 2 decimal places## Code Style Preferences
**TypeScript**:- Prefer `interface` over `type` for object shapes- Use `unknown` instead of `any` when type is truly unknown- Enable `strict` mode (already enabled in tsconfig.json)
**Functions**:- Prefer named exports over default exports- Use arrow functions for callbacks- Use function declarations for top-level functions
**Naming Conventions**:- Variables: camelCase- Constants: SCREAMING_SNAKE_CASE- Classes: PascalCase- Files: kebab-case.ts (e.g., `user-service.ts`)
**Imports**:- Use path aliases: `@/services/user` instead of `../../services/user`- Group imports: external, internal, types- Sort imports alphabetically within groupsFramework-Specific Patterns
Express.js Controllers:
{ status, data } or { status, message }// Good: Thin controllerexport async function getTask(req: Request, res: Response) { const task = await taskService.getById(req.params.id); return res.json({ status: 'success', data: { task } });}
// Bad: Business logic in controllerexport async function getTask(req: Request, res: Response) { const task = await db.query.tasks.findFirst(/* ... */); if (!task) throw new Error('Not found'); // ... 20 more lines}Drizzle ORM Queries:
.returning() for insert/update operations// Good: Drizzle query builderconst [user] = await db .insert(users) .values({ name, email }) .returning();
// Bad: Raw SQLconst user = await db.execute(sql`INSERT INTO users ...`);Testing Patterns
Unit Tests:
user.service.ts → user.service.test.ts// Good: Descriptive test nameit('should throw 404 error when task does not exist', async () => { await expect(service.getById('invalid-id')) .rejects.toThrow(new AppError('Task not found', 404));});
// Bad: Vague test nameit('works correctly', async () => { // What does "works correctly" mean?});Test Structure:
Coverage Goals:
Open VS Code in your project
code your-projectTest: Inline Suggestions
Create a new file src/services/user.service.ts and start typing:
import { db } from '@/db';import { users } from '@/models';
export class UserService { async createUserExpected: Copilot suggests a function signature matching your patterns:
async createUser(data: { name: string; email: string }) { const [user] = await db .insert(users) .values(data) .returning();
return user;}Test: Security Rules
Type a comment that violates security rules:
// Store JWT token in localStorageExpected: Copilot should NOT suggest localStorage.setItem(...) because .github/copilot-instructions.md forbids it.
Test: Chat Integration
Open Copilot Chat (Cmd+Shift+I) and ask:
“What’s our authentication pattern?”
Expected: Copilot references .github/copilot-instructions.md and summarizes:
Test: Code Explanation
Highlight a function and ask Copilot Chat:
“Does this follow our error handling pattern?”
Expected: Copilot checks if the code uses AppError class (as specified in .github/copilot-instructions.md).
GitHub Copilot Chat supports custom agents that can read your documentation:
## Copilot Chat Commands
**@workspace**: Ask about the entire codebase- Example: "@workspace where is the authentication middleware?"
**@terminal**: Execute commands and explain output- Example: "@terminal run npm test and explain failures"
**Custom Slash Commands**:- `/explain`: Explain highlighted code- `/fix`: Suggest fixes for linting errors- `/tests`: Generate tests for highlighted functionCursor is an AI-powered code editor built on VS Code. It reads .cursorrules to understand project conventions.
Download Cursor
Visit cursor.sh and download the installer for your OS.
Migrate from VS Code (optional)
Cursor can import your VS Code settings:
Cursor → Settings → General → Import VS Code SettingsEnable AI features
Cursor requires an account (free tier available):
Cursor → Sign In → Create AccountCursor reads .cursorrules from the project root. This file uses the same format as CLAUDE.md.
Two approaches:
# Copy CLAUDE.md to .cursorrulescp CLAUDE.md .cursorrules
# Add .cursorrules to .gitignore (if team uses different editors)echo ".cursorrules" >> .gitignorePros:
Cons:
# Create symlink from .cursorrules to CLAUDE.mdln -s CLAUDE.md .cursorrules
# Commit symlink to Gitgit add .cursorrulesgit commit -m "chore: link .cursorrules to CLAUDE.md"Pros:
Cons:
If you choose to maintain a separate .cursorrules file, customize it for Cursor’s strengths:
# Cursor Rules for [Project Name]
See `CLAUDE.md` for full project conventions.
## Tech Stack
- TypeScript (strict mode)- Express.js API- PostgreSQL with Drizzle ORM- Jest + Playwright for testing
## Critical Rules
- Never commit secrets (API keys, passwords)- Use RS256 JWT tokens (not HS256)- Store tokens in httpOnly cookies (not localStorage)- Follow patterns in `docs/core/PATTERNS.md`
## Cursor-Specific Workflows
**Multi-File Edits**:- Use Cmd+K for inline edits (single file)- Use Chat for multi-file refactoring (e.g., renaming across files)
**Codebase Exploration**:- Use "@Codebase" in chat to search entire project- Ask: "@Codebase where is the authentication logic?"
**Pattern Application**:- Reference canonical examples: "Follow `src/services/tasks.service.ts` pattern"- Cursor will analyze the example and apply the pattern
## Quick Commands
- **Test**: `npm test`- **Lint**: `npm run lint`- **Dev Server**: `npm run dev` (http://localhost:3000)Open project in Cursor
cursor your-projectTest: Inline Edits (Cmd+K)
Open src/services/user.service.ts and place cursor on a function.
Press Cmd+K (or Ctrl+K) and type:
“Add error handling following our AppError pattern”
Expected: Cursor reads .cursorrules → docs/core/PATTERNS.md#error-handling and wraps the function in try/catch with AppError.
Test: Chat Context (@Codebase)
Open Cursor Chat (Cmd+L) and ask:
“@Codebase What’s our authentication pattern?”
Expected: Cursor searches the codebase, finds .cursorrules → docs/core/PATTERNS.md#authentication, and summarizes the pattern.
Test: Multi-File Refactoring
In Cursor Chat, ask:
“Rename
getUserTaskstofetchUserTasksacross all files”
Expected: Cursor identifies all occurrences and proposes changes across multiple files.
Test: Pattern Replication
In Cursor Chat, ask:
“Create a new ProjectService following the pattern in
src/services/tasks.service.ts”
Expected: Cursor analyzes tasks.service.ts and generates project.service.ts with the same structure (class, methods, error handling, tests).
Cursor Composer is a multi-file editing mode that applies changes across your codebase:
Open Composer
Press Cmd+Shift+I (or Ctrl+Shift+I)
Describe multi-file change
Type:
“Refactor all services to use dependency injection. Inject the database connection via constructor instead of importing
dbdirectly.”
Review proposed changes
Cursor shows a diff of all affected files.
Accept or reject
Review each file and accept/reject changes individually.
Each AI agent has strengths and weaknesses. Here’s when to use each:
| Feature | Claude Code | GitHub Copilot | Cursor |
|---|---|---|---|
| Inline Autocomplete | ❌ No | ✅ Excellent | ✅ Good |
| Multi-File Edits | ✅ Excellent | ❌ No | ✅ Excellent |
| Chat Interface | ✅ Terminal-based | ✅ VS Code sidebar | ✅ Built-in panel |
| Context Window | 200k tokens | ~4k tokens | ~32k tokens |
| Reads Documentation | ✅ CLAUDE.md | ⚠️ Limited (100 lines) | ✅ .cursorrules |
| Autonomous Workflows | ✅ Yes (follows CLAUDE.md) | ❌ No | ⚠️ Limited |
| Code Explanation | ✅ Excellent | ✅ Good | ✅ Good |
| Test Generation | ✅ Excellent | ✅ Good | ✅ Good |
| Refactoring | ✅ Excellent | ❌ Limited | ✅ Excellent |
| Cost | Free tier + paid | $10-20/month | Free tier + paid |
Daily Coding
Use Copilot
Fast inline autocomplete for variable names, function signatures, and repetitive code.
Feature Implementation
Use Claude Code or Cursor
Understands broader context, follows patterns, generates tests.
Large Refactoring
Use Cursor Composer
Multi-file edits with preview and granular accept/reject.
Architectural Decisions
Use Claude Code
Reads ADRs, suggests alternatives, creates documentation.
You can use all three agents together for maximum productivity:
Planning (Claude Code)
Ask Claude Code:
“Read NEXT-TASKS.md and create a plan for implementing the ‘User Profile’ feature”
Claude does:
NEXT-TASKS.md to understand requirementsdocs/core/PATTERNS.md for existing patternsImplementation (Copilot + Cursor)
Copilot: Use for inline autocomplete while writing:
Cursor: Use Cmd+K for:
Testing (Claude Code)
Ask Claude Code:
“Generate unit tests for UserProfileService”
Claude does:
docs/core/PATTERNS.md#testingnpm test to verifyRefactoring (Cursor Composer)
After initial implementation, use Cursor Composer:
“Refactor UserProfileService to use dependency injection”
Cursor does:
user-profile.service.tsuser-profile.service.test.ts (mocks)src/index.ts (service instantiation)Documentation (Claude Code)
Ask Claude Code:
“Update docs/core/PATTERNS.md with the user profile pattern”
Claude does:
Validation (Claude Code)
Ask Claude Code:
“Run the post-task protocol”
Claude does:
cortex-tms validate --strictnpm testNEXT-TASKS.md to mark task completeSymptoms:
.cursorrulesSolutions:
Verify CLAUDE.md exists
ls -la CLAUDE.mdIf missing, run cortex-tms init to regenerate.
Check file encoding
CLAUDE.md must be UTF-8 encoded:
file CLAUDE.md# Output: CLAUDE.md: UTF-8 Unicode textTest with explicit reference
Ask: “Read CLAUDE.md and summarize the operational loop”
If Claude can’t read it, report a bug.
Verify .github/copilot-instructions.md exists
ls -la .github/copilot-instructions.mdCheck file size
Must be under 100 lines:
wc -l .github/copilot-instructions.md# Output: 68 .github/copilot-instructions.mdIf over 100 lines, move details to CLAUDE.md and reference it.
Restart VS Code
Copilot caches instructions. Reload window:
Cmd+Shift+P → Reload WindowVerify .cursorrules exists
ls -la .cursorrulesIf symlink, ensure target exists:
readlink .cursorrules# Output: CLAUDE.mdCheck Cursor settings
Open Settings → Search “cursorrules” → Ensure enabled
Reload Cursor
Cmd+Shift+P → Reload WindowSymptoms:
Solutions:
Add security rule to instructions
Edit .github/copilot-instructions.md (or .cursorrules):
## Critical Rules (Security)
**NEVER**:- Store tokens in localStorage (use httpOnly cookies)- Use HS256 for JWT (use RS256)- Commit secrets to Git (use environment variables)Move security rules to the top
AI agents prioritize early content. Put critical rules first.
Use explicit negative examples
## Authentication (Critical)
✅ **Good**: RS256 JWT tokens in httpOnly cookies```typescriptres.cookie('refreshToken', token, { httpOnly: true, secure: true, sameSite: 'strict',});❌ Bad: HS256 tokens in localStorage
// NEVER DO THISlocalStorage.setItem('token', token);Symptoms:
docs/core/PATTERNS.mdSolutions:
Add canonical examples to PATTERNS.md
AI agents learn better from examples than descriptions:
## Authentication Pattern
**Canonical Example**: `src/middleware/auth.middleware.ts`
```typescript// Copy the ENTIRE implementation hereexport async function authenticateToken(req, res, next) { // ... full code}Reference patterns explicitly in NEXT-TASKS.md
Instead of: “Implement authentication”
Write: “Implement authentication following docs/core/PATTERNS.md#authentication (RS256, 15-min expiry, httpOnly cookies)”
Use pattern validation
After AI generates code, ask:
“Does this code follow our authentication pattern from PATTERNS.md?”
AI will self-correct if it finds discrepancies.
Keep Instructions Under 100 Lines
GitHub Copilot has a 100-line limit for .github/copilot-instructions.md. Use references to longer docs.
Update Docs as You Learn
When AI makes a mistake, update PATTERNS.md with the correct approach. This prevents future errors.
Use Canonical Examples
Point AI to real files: “Follow src/services/tasks.service.ts pattern”. Examples are better than descriptions.
Security Rules First
Put critical security rules at the top of instruction files. AI agents prioritize early content.
Test AI Integration Early
After setting up TMS, test each AI agent with sample tasks. Fix documentation gaps immediately.
Commit AI-Generated Code Carefully
Always review AI suggestions. Run tests and linting before committing.
Now that you’ve integrated AI agents with Cortex TMS: