Custom AI Extensions & Agents
Build your own Copilot extensions, Claude Code tools, and team-specific AI workflows
Beyond Off-the-Shelf AI Tools
Generic AI tools are powerful, but the highest leverage comes from customizing them to your team's specific context: your coding conventions, internal APIs, deployment workflows, and domain knowledge. This lesson covers how to build that customization layer.
Claude Code Custom Commands
Claude Code supports custom slash commands defined in Markdown files. These let you encode team workflows as reusable prompts.
mkdir -p .claude/commands # Personal commands (not committed): mkdir -p ~/.claude/commands
# .claude/commands/pr-review.md Review the staged changes as a senior engineer on this team. Our standards: - All functions must have JSDoc comments - Error handling must use our AppError class from src/lib/errors.ts - No console.log — use the logger from src/lib/logger.ts - All async functions need try/catch Flag violations with file and line number. Suggest fixes using our existing patterns.
claude /pr-review # Claude Code reads the command file and executes it # with full access to your codebase context
CLAUDE.md — Project Context File
The CLAUDE.md file in your repo root is automatically read by Claude Code at the start of every session. It gives the AI persistent context about your project.
# CLAUDE.md (commit this to your repo) ## Project Overview This is a multi-tenant SaaS platform for invoice management. Backend: Node.js + Express + PostgreSQL Frontend: Next.js 14 App Router + Tailwind ## Code Conventions - Use named exports only (no default exports) - All DB queries go through src/db/queries/ — never inline SQL - Error handling: throw AppError instances, never raw Error - Logging: import logger from '@/lib/logger', never console.log ## Key Files - src/db/schema.ts — database types - src/lib/auth.ts — authentication utilities - docs/api.md — API documentation ## Testing - Use vitest + testing-library - Test files: *.test.ts alongside source files - Run: npm test (watch), npm run test:ci (CI)
MCP Servers — Tool Extensions
Model Context Protocol (MCP) lets you give Claude Code access to external tools: databases, APIs, file systems, and custom services. Any tool your team uses can become a Claude Code capability.
# Add an MCP server to Claude Code:
# ~/.claude/claude_desktop_config.json
{
"mcpServers": {
"postgres": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-postgres"],
"env": {
"POSTGRES_CONNECTION_STRING": "postgresql://localhost/mydb"
}
},
"github": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-github"],
"env": { "GITHUB_TOKEN": "your-token" }
}
}
}
# Now Claude Code can:
# - Query your database directly
# - Read GitHub issues and PRs
# - Create issues from code TODOsBuilding a Custom MCP Server
Build your own MCP server to give Claude Code access to your internal tools:
# Install the MCP SDK:
npm install @modelcontextprotocol/sdk
# src/mcp-server.ts — minimal example
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
const server = new Server(
{ name: 'internal-tools', version: '1.0.0' },
{ capabilities: { tools: {} } }
);
// Register a tool Claude Code can call:
server.setRequestHandler('tools/call', async (request) => {
if (request.params.name === 'get_feature_flag') {
const flag = await fetchFromFlagService(request.params.arguments.flag_name);
return { content: [{ type: 'text', text: JSON.stringify(flag) }] };
}
});
const transport = new StdioServerTransport();
await server.connect(transport);
// Now claude can: "Check if the new-checkout feature flag is enabled in production"GitHub Copilot Extensions
Copilot Extensions let you build custom @agent integrations that appear in Copilot Chat. Your teammates invoke them with @your-agent.
# Copilot Extensions are GitHub Apps with special capabilities # They respond to @mentions in Copilot Chat # Use cases: # @docs — search internal documentation # @deploy — check deployment status, trigger deploys # @oncall — who's on call, open incidents # @runbook — fetch runbook for a service # To build one: # 1. Create a GitHub App at github.com/settings/apps # 2. Enable Copilot Extension capability # 3. Implement the extension API endpoint # 4. Handle the request format from GitHub # 5. Return streaming responses in the Copilot format # The extension receives: the user's message + conversation context # It returns: streamed text back to Copilot Chat
Team AI Playbook
Combine everything in this level into a team-wide AI workflow standard:
# Team AI Playbook — what to standardize: # 1. CLAUDE.md in every repo (project context) # 2. Shared .claude/commands/ committed to repos # - /pr-review — pre-PR checklist # - /onboard — explain the codebase to new devs # - /debug — structured debugging workflow # 3. Agreed prompt patterns for common tasks: # - Commit messages: conventional commits format # - PR descriptions: summary + test plan + breaking changes # - Code review: always ask for severity classification # 4. MCP servers for shared tooling: # - Internal docs # - Feature flags # - Deployment pipelines # 5. AI usage guidelines: # - Always review AI-generated code before committing # - No AI-generated code in security-critical paths without senior review # - AI for acceleration, not substitution of understanding
CLAUDE.md file in one of your real projects. Include: project overview, tech stack, key conventions (naming, error handling, logging), and important file locations. Run Claude Code in that project and notice how much more contextual its responses become.Repo-root file auto-read by Claude Code; encodes project context and conventions
.claude/commands/name.md — invoke with /name in Claude Code
Tool extension that gives Claude Code access to external systems
GitHub App with @agent interface — team-level internal tool integrations
Shared CLAUDE.md + commands + MCP servers + agreed prompt patterns
npm install @modelcontextprotocol/sdk — build custom tool servers
~/.claude/claude_desktop_config.json — register MCP servers globally