Lesson 11: Production & Team Workflows
- Monitoring usage and managing costs to optimize Claude Code consumption
- Establishing team conventions with shared skills, hooks, and coding standards
- Integrating Claude Code with git workflows for commits and pull requests
- Implementing hooks to enforce conventions and automate workflows
- Securing API keys, secrets, and sensitive data in production environments
- Rolling out Claude Code across your organization with a phased deployment strategy
Introduction
You've mastered Claude Code as an individual developer—now it's time to scale it across your team. Production deployment isn't just about installing software on everyone's machines. It's about monitoring usage patterns, managing costs, establishing team-wide conventions, and ensuring security at every level.
In this lesson, you'll learn how to deploy Claude Code across your organization while maintaining control over quality, cost, and security. We'll cover everything from tracking consumption to creating shared skills that enforce your team's coding standards.
Usage Monitoring
Claude Code tracks usage based on your plan tier. Understanding your consumption patterns helps you optimize workflows and avoid hitting limits that could disrupt your team's productivity.
To check your current usage, run:
claude usage
This command displays several key metrics. You'll see your current usage period (weekly for Free plans, monthly for Pro and Team plans), requests used out of your total limit, the reset date for your limit, and the model you're currently using (Sonnet 4.5 by default).
Here's what typical output looks like:
Usage Report
============
Plan: Pro
Period: Monthly (Dec 1 - Dec 31, 2024)
Requests: 487 / 2000
Next reset: January 1, 2025
Model: claude-sonnet-4.5
For Team plans, administrators can see usage across all team members with claude usage --team. This shows total team consumption, per-member breakdowns, top consumers, and usage trends over time—essential data for identifying optimization opportunities.
Not every action you take counts equally toward your usage limit. Each Claude Code session turn counts as 1 request. When you spawn agents, those count as separate requests. However, tool use within a single turn (Read, Edit, Bash) doesn't add extra requests. If you resume an existing agent, that counts as a new request.
Monitor your usage weekly to spot trends before they become problems. Set up alerts when you hit 80% consumption so you can adjust workflows or plan around the limit. Identify which workflows consume the most requests and optimize them. If you have heavy tasks like large refactors planned, schedule them early in your usage period when you have the most requests available.
Cost Management
Staying within your usage limits requires understanding which workflows consume the most requests and how to optimize them.
Some patterns are particularly expensive. Spawning multiple agents sequentially when you could use one wastes requests. Asking vague questions that require extensive exploration burns through your limit quickly. Running the same analysis repeatedly instead of saving results is inefficient. Using general-purpose agents for simple edits is like using a sledgehammer to crack a nut.
Cost-effective patterns look different. Use parallel agents for independent tasks—they consume the same number of requests as sequential agents but finish faster. Resume agents for follow-up questions instead of spawning new ones. Cache research results in project documentation so you don't re-explore the same code. Use specific prompts that reduce back-and-forth exchanges.
Here's an expensive workflow:
You: Analyze the codebase
Claude: [spawns general-purpose agent, explores everything]
You: Now find all the API routes
Claude: [spawns another agent, re-explores]
You: Now find all the tests
Claude: [spawns third agent, re-explores]
This costs 3+ requests and wastes time with redundant exploration.
The optimized version uses parallel agents:
You: Spawn three Explore agents in parallel:
1. Map the overall architecture
2. Find all API routes
3. Find all tests
This costs 3 requests but runs simultaneously, saving time. Even better, you can consolidate:
You: Use an Explore agent to map the codebase structure, including
architecture, API routes, and test files
This costs just 1 request because the agent does comprehensive exploration in one pass.
The Task tool can use different models. Sonnet 4.5 (default) provides the best quality but is the most expensive. For simple, well-defined tasks, you can request Haiku: "Use a Haiku-powered agent to fix all the linting errors." This saves usage while handling straightforward work.
Team Conventions
When multiple developers use Claude Code, establishing conventions ensures consistency across your codebase and prevents each person from solving the same problems independently.
Create a team skills repository that everyone can share:
team-claude-skills/
├── README.md
├── deploy-staging/
│ └── SKILL.md
├── generate-changelog/
│ └── SKILL.md
├── validate-api-spec/
│ └── SKILL.md
└── update-deps/
└── SKILL.md
Team members clone this to their .claude/skills/ directory:
cd ~/.claude/skills
git clone [email protected]:company/team-claude-skills.git team
Now everyone has access to /team/deploy-staging, /team/validate-api-spec, and other shared skills. When you improve a skill, everyone benefits from the update with a simple git pull.
Hooks enforce team standards automatically. A pre-prompt hook runs before each prompt and can remind Claude about project conventions:
#!/bin/bash
# Remind Claude about project conventions
echo "Project conventions:"
echo "- Use Tailwind CSS, no custom CSS"
echo "- All API responses use {data, error, meta} envelope"
echo "- Tests go in __tests__/ directories"
A tool-use hook runs when Claude uses tools and can log usage for auditing:
#!/bin/bash
# Log tool usage for auditing
echo "$(date): $CLAUDE_TOOL_NAME used" >> ~/.claude/tool-usage.log
Store team conventions in your repository so they're version-controlled:
.claude/
├── hooks/
│ ├── user-prompt-submit-hook
│ └── tool-use-hook
├── skills/
│ └── (symlinked to team repo)
└── team-conventions.md
Developers sync conventions with a simple git pull origin main.
Git Integration Patterns
Claude Code has deep git integration. Understanding when and how to commit ensures clean history that's easy to review and understand.
The /commit skill automates thoughtful commits. It runs git status to see changes, runs git diff to understand what changed, analyzes commit history for message style, creates a conventional commit message, and commits with proper co-authoring.
When you use /commit, you might see output like:
Commit message:
feat: add user authentication with JWT
- Implement JWT token generation and validation
- Add login and signup endpoints
- Create authentication middleware
- Add tests for auth flow
Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
Good commit points include after completing a feature (use /commit after implementation), after fixing a bug (use /commit immediately), and before starting a new task to have a clean slate.
Avoid committing mid-task when code is incomplete, after every single file edit (batch related changes instead), and when tests are failing (fix first, then commit).
The /review-pr skill integrates with GitHub to fetch PRs, review code, check for issues, and provide structured feedback. When you've completed a feature, you can say "Create a PR" and Claude will push your branch and use the GitHub MCP to create a PR with a proper description.
The Hooks System
Hooks are shell scripts that run in response to events. They enforce conventions and automate workflows without requiring manual intervention.
Available hooks include user-prompt-submit-hook (runs before each prompt), tool-use-hook (runs when Claude uses a tool), conversation-start-hook (runs when session starts), and conversation-end-hook (runs when session ends).
Place hooks in ~/.claude/hooks/hook-name for global hooks, or .claude/hooks/hook-name for project-specific hooks.
Here's a hook that enforces test-first development:
#!/bin/bash
# Check if user is asking to implement something without tests
if echo "$CLAUDE_PROMPT" | grep -iq "implement\|add\|create"; then
echo "⚠️ Reminder: Have you written tests first?"
echo "Use '/generate-tests' to create test cases before implementing."
fi
This hook logs all file edits for auditing:
#!/bin/bash
if [ "$CLAUDE_TOOL_NAME" = "Edit" ]; then
echo "$(date): Edited $CLAUDE_TOOL_FILE" >> ~/.claude/audit.log
fi
Project-specific reminders help developers stay oriented:
#!/bin/bash
echo "📋 Current sprint: Real-time notifications"
echo "📖 See TASKS.md for todo list"
echo "⚙️ Run 'make dev' to start development server"
Hooks can prevent actions by exiting with non-zero status. This blocking hook prevents commits directly to main:
#!/bin/bash
# Prevent commits on main branch
BRANCH=$(git branch --show-current)
if [ "$BRANCH" = "main" ] && echo "$CLAUDE_PROMPT" | grep -q "/commit"; then
echo "❌ Cannot commit directly to main. Create a feature branch."
exit 1
fi
Security Best Practices
Claude Code accesses your codebase and can run commands. Security isn't optional—it's critical for protecting your organization's intellectual property and credentials.
Never hardcode API keys in prompts, commit .env files with real credentials, or share sessions with sensitive data in context. Always use environment variables for secrets, add .env to .gitignore, rotate API keys regularly, and use different keys for development and production.
MCP servers often need credentials. Store them securely by referencing environment variables:
{
"mcpServers": {
"postgres": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-postgres"],
"env": {
"DATABASE_URL": "${POSTGRES_URL}"
}
}
}
}
Set the environment variable separately in your shell configuration:
export POSTGRES_URL="postgresql://user:pass@localhost/db"
Use hooks to catch security issues before they reach your repository. This hook detects potential hardcoded secrets in edited files and warns you immediately.
#!/bin/bash
if [ "$CLAUDE_TOOL_NAME" = "Edit" ]; then
# Check for hardcoded secrets
if grep -q "API_KEY.*=" "$CLAUDE_TOOL_FILE"; then
echo "⚠️ Warning: Possible hardcoded API key in $CLAUDE_TOOL_FILE"
fi
fi
For Team plans, implement proper access control. Assign roles (admin, developer, viewer), limit access to production MCP servers, audit usage logs regularly, and review shared skills for security risks.
Rollout Strategy
Deploying Claude Code across your team requires planning. A phased approach reduces risk and ensures smooth adoption.
Phase 1: Pilot (Week 1-2) — Select 2-3 developers to pilot. They'll install and authenticate, create initial team skills, document common workflows, and gather feedback.
Phase 2: Early Adopters (Week 3-4) — Expand to 25% of your team. Share pilot findings, distribute the team skills repository, set up shared hooks, and monitor usage patterns to identify optimization opportunities.
Phase 3: Team Rollout (Week 5-6) — Full team deployment. Hold a mandatory onboarding session, distribute team conventions, set up usage monitoring, and establish a support channel for questions.
Phase 4: Optimization (Ongoing) — Continuous improvement. Review usage patterns monthly, update team skills based on feedback, optimize high-cost workflows, and add new MCP servers as needs evolve.
For each new team member, complete this onboarding checklist:
- Install Claude Code
- Authenticate with team account
- Clone team skills repository
- Configure shared hooks
- Connect required MCP servers (GitHub, Context7)
- Complete first workflow (guided exercise)
- Join team Slack channel for Claude Code questions
Monitoring Production Usage
Track team effectiveness with both individual and team-level metrics.
Individual metrics include requests per week, most-used tools (Read, Edit, Bash), most-used agents (Explore, Plan, general-purpose), and average session length. These help identify power users and usage patterns.
Team metrics include total requests consumed, top 10% users (are they getting value or hitting limits?), most popular skills, and commit frequency with Claude Code versus without. These metrics show organizational impact.
Quality metrics tell you if Claude Code is actually improving your development process. Track code review feedback on Claude-generated code, test pass rates for Claude-implemented features, time to complete features (before and after Claude Code), and developer satisfaction scores.
| Issue | Cause | Solution |
|---|---|---|
| Hitting usage limits frequently | Inefficient workflows | Audit high-usage patterns, optimize |
| Inconsistent code style | No team conventions | Establish shared hooks and skills |
| Security warnings in PRs | Hardcoded secrets | Add pre-commit hooks to catch issues |
| Slow adoption | Lack of training | Create onboarding materials, lunch & learns |
| Expensive MCP server costs | Unused connections | Audit MCP usage, disable unused servers |
| Commit message inconsistency | Not using /commit | Make /commit part of team workflow |
Exercise 11: Team Deployment Simulation
You'll set up a local "team environment" with shared skills, hooks, and monitoring.
1. Create a Team Skills Repository
Create a shared skills directory that simulates a team repository:
mkdir -p ~/.claude/skills/team
Create a team skill for validating code before committing:
# Pre-Commit Check
Run all pre-commit validations:
1. Run linter (eslint, pylint, or equivalent)
2. Run tests
3. Check for hardcoded secrets
4. Verify all files are formatted correctly
If any check fails, stop and report the issue.
2. Set Up Team Hooks
Create a hook that reminds you about team conventions:
mkdir -p .claude/hooks
cat > .claude/hooks/user-prompt-submit-hook << 'EOF'
#!/bin/bash
echo "🏢 Team Conventions:"
echo " - Use /pre-commit-check before committing"
echo " - All PRs need tests"
echo " - Follow conventional commit format"
EOF
chmod +x .claude/hooks/user-prompt-submit-hook
Create a tool-use hook that logs all edits:
cat > .claude/hooks/tool-use-hook << 'EOF'
#!/bin/bash
if [ "$CLAUDE_TOOL_NAME" = "Edit" ]; then
echo "$(date '+%Y-%m-%d %H:%M:%S') - Edited: $CLAUDE_TOOL_FILE" >> ~/.claude/team-audit.log
fi
EOF
chmod +x .claude/hooks/tool-use-hook
3. Test the Team Setup
Start a new Claude Code session and observe the team conventions reminder. Ask Claude to edit a file and verify the edit was logged:
tail -5 ~/.claude/team-audit.log
4. Check Usage Metrics
Run the usage command and note your current consumption:
claude usage
Calculate what percentage of your limit you've used this period.
5. Simulate Cost Optimization
Think about your recent Claude Code usage. Identify one workflow where you could have used fewer requests by using parallel agents or resuming instead of respawning. Write a brief note about how you'd optimize it.
Run through this exercise and you'll have hands-on experience with the team deployment patterns that keep Claude Code usage efficient and secure across organizations.
Summary
Production deployment of Claude Code requires more than just installation—it demands thoughtful monitoring, cost management, and security practices. You've learned to track usage with claude usage, optimize workflows to minimize request consumption, and establish team conventions through shared skills and hooks.
Git integration with /commit and /review-pr ensures consistent, well-documented changes. The hooks system enforces standards automatically, while security best practices protect your credentials and codebase. A phased rollout strategy reduces risk and ensures smooth adoption across your organization.
Next: You've completed Part 3: Building with Claude Code and Tier 1: Foundations & API Integration. In Tier 2, you'll build production-grade AI applications with advanced patterns including RAG systems, vector databases, and multi-agent orchestration.
Additional Resources
- Claude Code Team Administration — Managing team accounts and permissions
- Usage & Billing — Understanding costs and limits
- Hooks Reference — Complete hooks documentation
- Security Best Practices — Securing your Claude Code deployment
- Git Integration Guide — Advanced git workflows and automation