agentleFS
aws-samplesaws-samples/anthropic-on-aws/advanced-claude-code-patterns/CLAUDE.md

anthropic-on-aws / advanced-claude-code-patterns

CLAUDE.md443 starsChanged 3 months agoMIT-0View on GitHub

This is the Claude Code Advanced Patterns repository - a comprehensive package providing production-ready agents, hooks, commands, and workflow patterns for sophisticated AI-assisted development. The project contains no executable code but rather configuration files, documentation, and templates that extend Claude Code's capabilities.

  • Pipes a download into a shell
  • Installs packages

The file

Show its rules and text

We split this CLAUDE.md into the rules it gives an agent

21 rules. About 0 are common, 18 are distinctive, and 3 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈18

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 3

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Plan: Create implementation strategy

    line 126
  2. Distinctive:

    When creating or modifying agents:

    line 133
  3. Distinctive:

    Keep agents under 150 lines

    line 134
  4. Distinctive:

    Start with Quick Reference section immediately after frontmatter

    line 135
  5. Distinctive:

    Use Behavioral Contract (ALWAYS/NEVER) for consistency

    line 138
  6. Distinctive:

    All security-related agents use Opus model for maximum accuracy

    line 181
  7. Distinctive:

    Follow Diataxis framework (tutorial, how-to, reference, explanation)

    line 187
  8. Distinctive:

    Use semantic versioning for all components

    line 190
  9. Distinctive:

    Use appropriate model selection (sonnet vs opus) based on complexity

    line 196
  10. Very specific:

    Agent not found: Verify agent is in correct directory (~/.claude/agents/ or .claude/agents/)

    line 229
  11. Distinctive:

    Command not available: Check command installation and use tab completion

    line 230
  12. Very specific:

    MCP server issues: Use claude --mcp-debug for diagnostics

    line 232
  13. Very specific:

    Use claude /cost to monitor token usage

    line 235
  14. Distinctive:

    Prefer parallel agent deployment over sequential

    line 236
  15. Distinctive:

    Use appropriate model selection (sonnet for routine, opus for complex)

    line 237
  16. Distinctive:

    When working with this repository:

    line 242
  17. Distinctive:

    Always use the most specific agent for the task

    line 243
  18. Distinctive:

    Test all configurations before committing

    line 245
  19. Distinctive:

    Follow semantic commit message patterns

    line 246
  20. Distinctive:

    Update documentation when modifying components

    line 247
  21. Distinctive:

    Ensure cross-references are maintained between related components

    line 249

≈ “Common” is an estimate: at least 1 in 5 of the 27,641 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
CLAUDE.md

CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

Project Overview

This is the Claude Code Advanced Patterns repository - a comprehensive package providing production-ready agents, hooks, commands, and workflow patterns for sophisticated AI-assisted development. The project contains no executable code but rather configuration files, documentation, and templates that extend Claude Code's capabilities.

Essential Commands

Repository Management

# Clone repository
git clone https://github.com/aws-samples/anthropic-on-aws.git
cd anthropic-on-aws/advanced-claude-code-patterns

# Install Claude Code (if not already installed)
npm install -g @anthropic-ai/claude-code
# OR 
curl -fsSL claude.ai/install.sh | bash

# Set up project structure
mkdir -p .claude/{agents,commands,hooks}

Component Installation

# Install agents globally (available in all projects)
cp agents/*.md ~/.claude/agents/

# Install agents for current project only
cp agents/*.md .claude/agents/

# Install slash commands globally
cp commands/**/*.md ~/.claude/commands/

# Install hooks globally
cp hooks/*.{json,py} ~/.claude/hooks/

# Install MCP servers for integrations
claude mcp add github -- npx @modelcontextprotocol/server-github
claude mcp add filesystem -- npx @modelcontextprotocol/server-filesystem .

Testing Components

# Test agent availability
claude "List available agents"

# Test slash command (use tab completion)
claude /[TAB]

# Verify MCP server connectivity
claude mcp list
claude --mcp-debug

Architecture & Component Structure

Core System Architecture

The repository implements a distributed AI orchestration system with four main component types:

  1. Agents (agents/) - Specialized AI assistants for specific tasks (23 production agents)
  2. Commands (commands/) - Slash commands for workflow orchestration (19 commands with argument support)
  3. Hooks (hooks/) - Lifecycle event automation for quality gates and CI/CD (12 configurations)
  4. Templates (templates/) - Project-specific CLAUDE.md configurations (5 templates)

Agent Orchestration Pattern

# Single agent deployment
@security-reviewer

# Parallel agent orchestration (key architectural pattern)
@docs-tutorial-agent @docs-howto-agent @docs-reference-agent @docs-explanation-agent

# Cross-functional team deployment
@architect @security-reviewer @qa-engineer @deployment-agent

Command Structure with Arguments

# Documentation creation with smart routing
/docs-create "authentication system" --complete    # Creates all 4 doc types
/docs-create "API endpoints" --working            # Creates how-to + reference
/docs-create "concepts" --understanding           # Creates explanation + reference

# EPCC workflow commands
/epcc/epcc-explore "user authentication"          # Analysis phase
/epcc/epcc-plan                                    # Planning phase
/epcc/epcc-code                                    # Implementation phase
/epcc/epcc-commit                                  # Commit with message

# TDD workflow commands
/tdd/tdd-feature "user login"                     # TDD feature development
/tdd/tdd-bugfix "authentication timeout"          # TDD bug fixing

Key Design Patterns

1. Agent Specialization & Composition

Each agent has a single responsibility with specific tools and expertise:

  • Documentation Agents: docs-tutorial-agent, docs-howto-agent, docs-reference-agent, docs-explanation-agent
  • Architecture Agents: architect, system-designer, architecture-documenter
  • Security & Quality: security-reviewer, qa-engineer, test-generator
  • Performance: performance-profiler, optimization-engineer
  • Agile Roles: scrum-master, product-owner, business-analyst

2. Smart Model Selection Strategy

  • Sonnet (Default): 80% of operations - testing, documentation, simple refactoring
  • Opus (Complex): 20% of operations - security analysis, performance optimization, architecture

This achieves 70% cost reduction while maintaining quality.

3. Diataxis Documentation Framework

The repository implements the complete Diataxis framework for documentation:

  • Tutorial: Learning-oriented, hands-on guidance
  • How-to: Problem-solving, task-oriented guides
  • Reference: Information lookup, technical specifications
  • Explanation: Understanding-oriented, conceptual depth

4. EPCC (Explore-Plan-Code-Commit) Workflow

A systematic development methodology:

  1. Explore: Analyze codebase and requirements
  2. Plan: Create implementation strategy
  3. Code: Execute development with agents
  4. Commit: Generate semantic commit messages

Working with Components

Agent Development

When creating or modifying agents:

  • Keep agents under 150 lines
  • Start with Quick Reference section immediately after frontmatter
  • Include specific activation instructions (5-6 lines max)
  • Define clear Core Identity with role and principles
  • Use Behavioral Contract (ALWAYS/NEVER) for consistency
  • Select minimum necessary tools
  • Include working code examples

Hook Configuration

Hooks use JSON configuration with Python scripts:

{
  "name": "quality-gates",
  "description": "Pre-commit quality validation",
  "hooks": {
    "pre-commit": [
      {
        "type": "command",
        "command": "python hooks/python_lint.py",
        "blocking": true,
        "description": "Run Python linting"
      }
    ]
  }
}

Command Creation

Slash commands support arguments and flags:

---
name: my-command
description: Brief description
argument-hint: "[required-arg] [--optional-flag]"
---

## Command Implementation
Handle missing arguments gracefully:
if not $ARGUMENTS:
    ask user for required input

Deploy appropriate agents based on arguments.

Quality Standards

Security Best Practices

  • All security-related agents use Opus model for maximum accuracy
  • Security scanning is mandatory before deployment (@security-reviewer)
  • Dependencies must be checked for CVEs
  • Authentication/authorization paths require validation

Documentation Standards

  • Follow Diataxis framework (tutorial, how-to, reference, explanation)
  • Include working code examples that are tested
  • Maintain consistent cross-references between documentation types
  • Use semantic versioning for all components

Performance Requirements

  • Agents must complete tasks within 2-minute timeouts
  • Hook execution should not exceed 30 seconds
  • Parallel agent deployment preferred over sequential
  • Use appropriate model selection (sonnet vs opus) based on complexity

Advanced Usage Patterns

Multi-Agent Workflows

# Complete security audit workflow
@security-reviewer @code-archaeologist @qa-engineer @deployment-agent

# Documentation generation workflow  
@docs-tutorial-agent @docs-howto-agent @docs-reference-agent @docs-explanation-agent @documentation-agent

# Architecture design workflow
@system-designer @tech-evaluator @architecture-documenter

Integration with External Tools

The repository supports MCP server integration for:

  • GitHub API access
  • Database connections
  • Cloud services
  • File system operations
  • Git repository management

Enterprise Patterns

  • Compliance automation with regulatory hooks
  • Multi-team agent orchestration
  • Audit trail generation
  • Progressive deployment patterns

Troubleshooting

Common Issues

  1. Agent not found: Verify agent is in correct directory (~/.claude/agents/ or .claude/agents/)
  2. Command not available: Check command installation and use tab completion
  3. Hook not triggering: Validate JSON syntax and verify hook configuration
  4. MCP server issues: Use claude --mcp-debug for diagnostics

Performance Issues

  • Use claude /cost to monitor token usage
  • Prefer parallel agent deployment over sequential
  • Use appropriate model selection (sonnet for routine, opus for complex)
  • Implement caching strategies for repeated operations

Development Workflow

When working with this repository:

  1. Always use the most specific agent for the task
  2. Leverage parallel agent orchestration for complex workflows
  3. Test all configurations before committing
  4. Follow semantic commit message patterns
  5. Update documentation when modifying components
  6. Validate all JSON configurations for syntax errors
  7. Ensure cross-references are maintained between related components

File Organization

advanced-claude-code-patterns/
├── agents/              # 23 specialized AI agents
├── commands/            # 19 slash commands with args
│   ├── docs/           # Documentation workflow commands
│   ├── epcc/           # EPCC methodology commands  
│   └── tdd/            # Test-driven development commands
├── hooks/               # 12 lifecycle automation configs
├── templates/           # 5 project-specific CLAUDE.md files
├── docs/                # Comprehensive implementation guides
├── integrations/        # MCP server integration patterns
└── presentation/        # Project overview materials

This architecture enables sophisticated AI-assisted development workflows while maintaining modularity, reusability, and production-quality standards.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.