HomeClaude Code for TeamsTeam Workflows & Best Practices
intermediate12 min read· Module 12, Lesson 5

📋Team Workflows & Best Practices

Shared CLAUDE.md, team commands, and collaboration patterns

Team Workflows & Best Practices

As teams grow, individual productivity tools must evolve into shared workflows. Claude Code offers several mechanisms for team-wide consistency: shared CLAUDE.md files, custom slash commands, MCP server configurations, and coding standards enforcement. This lesson covers every aspect of building a productive, consistent team workflow around Claude Code.


Shared CLAUDE.md: The Team Playbook

The CLAUDE.md file is the single most important artifact for team alignment. It tells Claude how your team works, what conventions to follow, and what mistakes to avoid. There are three levels of CLAUDE.md files:

LevelLocationScope
Global~/.claude/CLAUDE.mdPersonal preferences across all projects
Project./CLAUDE.md (repo root)Shared team standards for a project
Local./src/feature/CLAUDE.mdModule-specific rules

Project-level CLAUDE.md is the team playbook. It should be committed to the repository so every team member and every Claude session inherits the same rules.

What to Include in a Team CLAUDE.md

A well-structured team CLAUDE.md typically contains these sections:

Markdown
# Project: MyApp ## Architecture - Monorepo with apps/ and packages/ directories - Backend: Node.js + Express + PostgreSQL - Frontend: Next.js 14 with App Router - Shared types in packages/shared-types ## Coding Standards - Use TypeScript strict mode everywhere - Prefer named exports over default exports - All API endpoints must have Zod validation schemas - Database queries go through the repository pattern - Never use any type — use unknown and narrow ## Testing Requirements - Every new function needs unit tests - Integration tests for API endpoints - Minimum 80% coverage for new code - Use vitest for unit tests, playwright for e2e ## Git Conventions - Branch format: feature/TICKET-123-short-description - Commit format: type(scope): description - Always squash merge to main - Never force push to shared branches ## PR Standards - Must include a summary and test plan - All checks must pass before review - Minimum one approval required - Link to the relevant ticket in description ## Forbidden Patterns - Do NOT use console.log in production code — use the logger utility - Do NOT commit .env files - Do NOT use raw SQL — use the query builder - Do NOT skip error handling — wrap async calls in try/catch

Keeping CLAUDE.md Up to Date

A stale CLAUDE.md is worse than none at all. Establish a process:

  1. Review CLAUDE.md in every architecture decision — when you change a pattern, update CLAUDE.md
  2. Add a CI check — lint the CLAUDE.md for common issues
  3. Assign an owner — one person (or a rotating role) reviews CLAUDE.md monthly
  4. Use PRs for changes — treat CLAUDE.md edits like code changes with review

Team Custom Slash Commands

Custom slash commands let you package complex workflows into simple, repeatable actions. They live in the .claude/commands/ directory and are shared via version control.

Creating Team Commands

Create a directory for team-wide commands:

Terminal
mkdir -p .claude/commands

Each command is a markdown file. The filename becomes the command name.

Example: Code Review Command (.claude/commands/review.md)

Markdown
Review the current staged changes with the following checklist: 1. Check for TypeScript type safety issues 2. Verify error handling is complete 3. Ensure all new functions have JSDoc comments 4. Look for potential performance issues 5. Verify naming conventions match our standards 6. Check for security vulnerabilities (SQL injection, XSS, etc.) 7. Ensure tests cover the happy path and at least one error case Output a structured report with: - Summary of changes - Issues found (critical / warning / info) - Suggestions for improvement - Overall assessment (approve / request changes)

Example: New Feature Scaffold (.claude/commands/scaffold-feature.md)

Markdown
Create a new feature module with the standard structure: 1. Create the directory: src/features/$ARGUMENTS/ 2. Add the following files: - index.ts (barrel export) - types.ts (TypeScript interfaces) - service.ts (business logic) - controller.ts (API handler) - repository.ts (database access) - validator.ts (Zod schemas) - __tests__/service.test.ts - __tests__/controller.test.ts 3. Register routes in src/routes/index.ts 4. Add the feature to the README features list

Example: Database Migration (.claude/commands/create-migration.md)

Markdown
Create a new database migration for: $ARGUMENTS 1. Generate a timestamped migration file in db/migrations/ 2. Include both up and down functions 3. Add appropriate indexes for any new columns 4. Update the schema types in packages/shared-types 5. Create or update the repository methods 6. Add a test for the migration rollback

Organizing Commands by Role

For larger teams, organize commands by role or function:

.claude/commands/ review.md scaffold-feature.md create-migration.md fix-lint.md write-tests.md update-docs.md debug-issue.md optimize-query.md

Onboarding New Team Members

A strong onboarding workflow helps new developers become productive quickly. Claude Code can accelerate this significantly.

The Onboarding CLAUDE.md Section

Add an onboarding section to your CLAUDE.md:

Markdown
## Onboarding ### First Day Setup 1. Clone the repo and run: npm install 2. Copy .env.example to .env and fill in local values 3. Start the database: docker compose up -d postgres 4. Run migrations: npm run db:migrate 5. Start dev server: npm run dev 6. Run tests to verify: npm run test ### Key Concepts - We use the repository pattern for all database access - API validation happens at the controller level with Zod - Auth is handled via JWT tokens stored in httpOnly cookies - Background jobs run through BullMQ with Redis ### Where to Find Things - API routes: src/routes/ - Business logic: src/features/ - Shared types: packages/shared-types/ - Database schemas: db/schemas/ - E2E tests: tests/e2e/

Onboarding Slash Command

Create a dedicated onboarding command (.claude/commands/onboard.md):

Markdown
Help me understand this codebase. Walk me through: 1. The overall architecture and directory structure 2. How a typical API request flows through the system 3. The database schema and key relationships 4. The testing strategy and how to run tests 5. The deployment pipeline 6. Any critical things a new developer should know Be thorough but concise. Use diagrams where helpful.

Code Review Standards

Consistent code reviews are essential for code quality. Define clear standards and use Claude to enforce them.

Automated Review Checklist

Create a review standards document and reference it in your CLAUDE.md:

Markdown
## Code Review Standards ### Must Pass (Blocking) - No TypeScript errors or warnings - All tests pass - No secrets or credentials in code - Error handling for all async operations - Input validation for all external data - No breaking changes to public APIs without version bump ### Should Pass (Non-blocking) - Functions under 50 lines - Files under 300 lines - Clear variable and function names - JSDoc for exported functions - Performance considerations documented - Accessibility compliance for UI changes ### Nice to Have - Code examples in documentation - Benchmark results for performance-sensitive changes - Screenshots for UI changes

Using Claude for PR Reviews

You can integrate Claude into your PR review workflow:

Terminal
# Review a specific PR gh pr diff 42 | claude "Review this PR diff against our team standards in CLAUDE.md"

Create a CI step that runs Claude review automatically:

YAML
# .github/workflows/claude-review.yml name: Claude Code Review on: pull_request: types: [opened, synchronize] jobs: review: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Run Claude Review run: | gh pr diff ${{ github.event.pull_request.number }} > diff.txt claude --print "Review this diff against our CLAUDE.md standards" < diff.txt

Shared MCP Servers

Model Context Protocol (MCP) servers extend Claude's capabilities with external tools. Teams can share MCP server configurations for consistency.

Team MCP Configuration

MCP servers are configured in .claude/settings.json at the project level:

JSON
{ "mcpServers": { "database": { "command": "npx", "args": ["@modelcontextprotocol/server-postgres", "postgresql://localhost:5432/myapp"], "env": {} }, "jira": { "command": "npx", "args": ["@modelcontextprotocol/server-jira"], "env": { "JIRA_URL": "https://myteam.atlassian.net", "JIRA_TOKEN_ENV": "JIRA_API_TOKEN" } }, "github": { "command": "npx", "args": ["@modelcontextprotocol/server-github"], "env": { "GITHUB_TOKEN_ENV": "GITHUB_TOKEN" } } } }

Best Practices for Team MCP Servers

  1. Use environment variable references — never hardcode tokens in shared configs
  2. Document required environment variables — add them to .env.example
  3. Version pin MCP server packages — avoid breaking changes from updates
  4. Test MCP servers in CI — ensure they start correctly
  5. Limit server permissions — use read-only database connections where possible

Coding Standards Enforcement

Beyond documentation, you can actively enforce standards through Claude Code.

Pre-commit Hooks with Claude

Add Claude-powered checks to your workflow:

Terminal
# .claude/commands/pre-commit-check.md Check the staged files for: 1. Any use of console.log (should use logger) 2. Missing error handling in async functions 3. Raw SQL queries (should use query builder) 4. Hardcoded secrets or API keys 5. Missing TypeScript types (no implicit any) Report violations with file paths and line numbers.

Style Guide Enforcement

Include specific style rules in CLAUDE.md that Claude will follow:

Markdown
## Style Enforcement ### Naming Conventions - Components: PascalCase (UserProfile.tsx) - Hooks: camelCase with use prefix (useAuth.ts) - Utilities: camelCase (formatDate.ts) - Constants: SCREAMING_SNAKE_CASE (MAX_RETRY_COUNT) - Types/Interfaces: PascalCase with no I prefix (UserProfile, not IUserProfile) ### Import Order 1. Node built-ins (path, fs) 2. External packages (react, express) 3. Internal packages (@myapp/shared) 4. Relative imports (./utils) 5. Type imports (type { User }) ### File Structure - Exports at the top - Types and interfaces next - Constants after types - Main logic in the middle - Helper functions at the bottom

Collaboration Patterns

Effective team collaboration with Claude requires agreed-upon patterns.

The Session Handoff Pattern

When one developer starts work and another continues:

  1. Document context in comments — leave TODO comments explaining the current state
  2. Use descriptive branch names — include the ticket number and a brief description
  3. Write a handoff note — summarize what was done, what remains, and any blockers
  4. Commit frequently — small commits make it easier for the next person to understand progress

The Pair Programming Pattern

Two developers can use Claude together effectively:

  1. Driver writes code with Claude — one person runs Claude and makes changes
  2. Navigator reviews in real-time — the other person watches and catches issues
  3. Switch roles regularly — every 30 minutes, swap who controls Claude
  4. Share the session context — use a shared CLAUDE.md with pair-specific notes

The Review-First Pattern

Before writing code, use Claude to review the approach:

Terminal
claude "I need to implement user authentication with OAuth 2.0. Review our current auth setup in src/auth/ and suggest the best approach that fits our existing patterns."

This prevents wasted effort on approaches that do not fit the codebase.

The Documentation-Driven Pattern

Write documentation before implementation:

  1. Write the API contract first (OpenAPI spec or TypeScript types)
  2. Have Claude review the contract for completeness
  3. Implement the feature following the contract
  4. Claude validates the implementation matches the contract

Measuring Team Productivity

Track how Claude impacts your team's productivity to justify investment and improve workflows.

Key Metrics to Track

MetricHow to MeasureTarget
Time to First CommitTrack from onboarding start to first merged PRUnder 2 days
PR Cycle TimeTime from PR open to mergeUnder 24 hours
Code Review TurnaroundTime from review request to first reviewUnder 4 hours
Bug Escape RateBugs found in production vs caught in reviewUnder 5%
Test Coverage DeltaCoverage change per sprintPositive trend
Developer SatisfactionMonthly survey scoreAbove 8/10

Tracking Claude Usage

Monitor how your team uses Claude to identify improvement opportunities:

Markdown
## Weekly Claude Retrospective Questions 1. What tasks did Claude handle well this week? 2. Where did Claude struggle or produce incorrect output? 3. Are there new patterns we should add to CLAUDE.md? 4. Did anyone discover a useful new workflow? 5. Are there repetitive tasks we should automate with commands?

Migration Guide: Adopting Team Workflows

If your team is already using Claude individually, follow this migration path to adopt team workflows.

Phase 1: Foundation (Week 1)

  1. Create the project CLAUDE.md — gather input from all team members
  2. Document existing conventions — write down what people already follow informally
  3. Set up the commands directory — create 2-3 initial team commands
  4. Commit everything — push CLAUDE.md and commands to the shared repo

Phase 2: Standardization (Week 2-3)

  1. Add code review standards — define the review checklist
  2. Configure shared MCP servers — set up database and project management integrations
  3. Create onboarding documentation — write the onboarding section and command
  4. Train the team — run a workshop on using shared commands and CLAUDE.md

Phase 3: Optimization (Week 4+)

  1. Collect feedback — run the weekly retrospective
  2. Refine CLAUDE.md — update based on real-world usage
  3. Add new commands — automate frequently requested workflows
  4. Measure impact — track the metrics defined above

Common Migration Mistakes

MistakeWhy It HappensHow to Avoid
Overloading CLAUDE.mdTrying to document everything at onceStart with top 10 rules, expand gradually
Ignoring personal preferencesForcing everyone into identical workflowsAllow personal CLAUDE.md for individual style
Not updating docsCLAUDE.md drifts from realityMonthly review process with assigned owner
Too many commandsCreating commands for rare tasksOnly automate tasks done at least weekly
Skipping trainingAssuming people will figure it outRun a 30-minute intro session for the team

Summary

Building effective team workflows with Claude Code requires:

  1. A shared CLAUDE.md that documents architecture, standards, and conventions
  2. Custom slash commands for repeatable team workflows
  3. Structured onboarding that gets new members productive quickly
  4. Clear code review standards enforced consistently
  5. Shared MCP servers for consistent tooling across the team
  6. Coding standards enforcement through documentation and automation
  7. Collaboration patterns that fit your team's working style
  8. Measurable metrics to track and improve productivity
  9. A phased migration plan to adopt workflows incrementally

The key principle is consistency over perfection. A simple, shared workflow that everyone follows is far more valuable than a complex system that only one person understands.