Claude Code Prompt Library: 40+ Templates for the CLI
Ready-to-use prompt templates for Claude Code (Anthropic's CLI). Includes CLAUDE.md examples, hooks, PR review templates, refactoring prompts, and more.
Claude Code is Anthropic's official CLI for interacting with Claude directly in your terminal. These prompts help you get the most out of it.
- CLAUDE.md files — Project-specific instructions Claude reads automatically
- Hooks — Automate pre/post actions for Claude Code commands
- Prompt files — Reusable .prompt files for common tasks
- 40+ templates below for PR reviews, refactoring, testing, and more
What is Claude Code?
Claude Code is Anthropic's official command-line interface for Claude AI. Unlike the web interface, Claude Code lets you:
- Work directly in your codebase — Claude reads and writes files in your project
- Run terminal commands — Execute git, npm, tests, and more
- Use project context — CLAUDE.md files give Claude project-specific knowledge
- Automate with hooks — Pre/post-command automation
- Create reusable prompts — .prompt files for common workflows
Install with: npm install -g @anthropic-ai/claude-code
Save All 40+ Claude Code Templates
Don't copy-paste one by one. Create a free account to save all templates, organize by project, and access from any device.
CLAUDE.md File Templates
Project-specific instructions Claude reads automatically
CLAUDE.md# Project: {{PROJECT_NAME}}
## Tech Stack
- Next.js 15 (App Router)
- TypeScript (strict mode)
- Tailwind CSS + shadcn/ui
- Supabase (auth + database)
## Code Conventions
- Use 'use client' only when necessary
- Prefer Server Components by default
- Use Zod for form validation
- Error boundaries for error handling
## File Structure
- src/app/ - App Router pages
- src/components/ - Reusable components
- src/lib/ - Utilities and helpers
- src/types/ - TypeScript types
## Commands
- npm run dev - Start development
- npm run build - Production build
- npm run test - Run tests
## Important Notes
- Always run build before committing
- Use conventional commits (feat:, fix:, etc.)
- Check TypeScript errors before pushingCLAUDE.md# Project: {{PROJECT_NAME}}
## Tech Stack
- Python 3.12+
- Poetry for dependency management
- FastAPI / Django / Flask
- PostgreSQL + SQLAlchemy
## Code Style
- Black formatter (line length 88)
- isort for imports
- Type hints required
- Docstrings for public functions
## Project Structure
- src/ - Main application code
- tests/ - Pytest test files
- scripts/ - Utility scripts
## Commands
- poetry install - Install dependencies
- poetry run pytest - Run tests
- poetry run black . - Format code
- poetry run mypy . - Type checking
## Development Rules
- All functions need type hints
- Tests required for new features
- Use async where appropriateCLAUDE.md# Monorepo: {{PROJECT_NAME}}
## Structure
- apps/web - Next.js frontend
- apps/api - Node.js backend
- packages/ui - Shared component library
- packages/utils - Shared utilities
## Tech Stack
- Turborepo for build orchestration
- pnpm workspaces
- TypeScript throughout
- Shared ESLint/Prettier configs
## Commands
- pnpm install - Install all dependencies
- pnpm dev - Run all apps in dev mode
- pnpm build - Build all packages
- pnpm test - Run all tests
- pnpm lint - Lint entire monorepo
## Package Dependencies
- packages/ui depends on packages/utils
- apps/* can import from packages/*
- Never import from apps/ into packages/
## Deployment
- apps/web deploys to Vercel
- apps/api deploys to Railway
- packages are internal onlyClaude Code Hooks
Automate pre/post actions for Claude Code commands
.claude/hooks/pre-commit.sh#!/bin/bash # Pre-commit hook for Claude Code echo "Running pre-commit checks..." # Run TypeScript type checking npm run typecheck if [ $? -ne 0 ]; then echo "TypeScript errors found. Please fix before committing." exit 1 fi # Run ESLint npm run lint if [ $? -ne 0 ]; then echo "Linting errors found. Please fix before committing." exit 1 fi # Run tests npm run test if [ $? -ne 0 ]; then echo "Tests failed. Please fix before committing." exit 1 fi echo "All checks passed!" exit 0
.claude/hooks/post-build.sh#!/bin/bash
# Post-build hook for Claude Code
echo "Build completed successfully!"
# Check bundle size
npm run analyze:bundle
# Run integration tests
npm run test:integration
# Notify on success
echo "✅ All post-build checks passed"
# Optional: Send notification
# curl -X POST "$WEBHOOK_URL" -d '{"text":"Build completed"}'.claude/hooks/on-file-change.sh#!/bin/bash
# Auto-review hook for Claude Code
# Get list of changed files
CHANGED_FILES=$(git diff --name-only HEAD~1)
for file in $CHANGED_FILES; do
echo "Reviewing: $file"
# Skip non-code files
if [[ ! "$file" =~ .(ts|tsx|js|jsx|py)$ ]]; then
continue
fi
# Claude will automatically review the file
echo "REVIEW_FILE=$file"
donePR Review Prompts
Get thorough code reviews from Claude Code
review-pr.promptReview this PR thoroughly. Check for: ## Security - SQL injection vulnerabilities - XSS attack vectors - Authentication/authorization issues - Sensitive data exposure - Insecure dependencies ## Performance - N+1 query problems - Unnecessary re-renders - Missing memoization - Large bundle impacts - Slow database queries ## Code Quality - TypeScript strict mode compliance - Proper error handling - Test coverage - Documentation completeness - Naming conventions ## Architecture - Separation of concerns - DRY principle violations - SOLID principles - API design consistency For each issue, provide: 1. File and line number 2. Severity (Critical/High/Medium/Low) 3. Clear explanation 4. Suggested fix with code
Security-focused review only. Check for: 1. Input validation issues 2. SQL/NoSQL injection 3. XSS vulnerabilities 4. CSRF protection 5. Authentication bypasses 6. Authorization flaws 7. Sensitive data in logs/responses 8. Hardcoded secrets 9. Insecure dependencies (npm audit) 10. Rate limiting gaps Skip style/formatting issues. Only flag security concerns. Rate each finding: Critical / High / Medium / Low
Testing Prompts
Generate comprehensive tests with Claude Code
generate-tests.promptGenerate unit tests for this file. Requirements:
## Test Framework
- Use {{Jest/Vitest/Pytest}}
- Use {{React Testing Library}} for components
## Coverage Goals
- All public functions
- Edge cases and error conditions
- Async operations
- Mock external dependencies
## Test Structure
- Descriptive test names
- Arrange-Act-Assert pattern
- One assertion per test (when possible)
- Group related tests
## Must Include
- Happy path tests
- Error handling tests
- Boundary conditions
- Null/undefined handling
- Type edge cases
Output the complete test file ready to run.Generate integration tests for this API endpoint: ## Test Setup - Use supertest for HTTP assertions - Setup/teardown test database - Mock external services - Handle authentication ## Test Cases 1. Happy path (200 response) 2. Validation errors (400) 3. Authentication required (401) 4. Authorization denied (403) 5. Not found (404) 6. Server errors (500) ## Request Variations - Valid/invalid request bodies - Missing required fields - Invalid field types - Pagination parameters - Filter parameters Include database assertions where needed.
Refactoring Prompts
Clean up and improve existing code
Refactor this React component: ## Goals 1. Convert class component to functional (if applicable) 2. Replace useState with useReducer if state is complex 3. Extract custom hooks for reusable logic 4. Add proper TypeScript types 5. Implement proper error boundaries 6. Add loading and error states 7. Memoize expensive computations 8. Split into smaller sub-components if >200 lines ## Constraints - Maintain existing functionality - Keep same prop interface (or provide migration) - Preserve existing test compatibility - Document breaking changes Show the refactored code with comments explaining changes.
Optimize this database query/code: ## Analysis Required 1. Identify N+1 query problems 2. Find missing indexes 3. Check for unnecessary data fetching 4. Review join efficiency 5. Analyze query execution plan ## Optimization Strategies - Add appropriate indexes - Use batch loading - Implement pagination - Add query caching - Optimize JOIN order - Use database-specific features ## Output 1. Optimized query/code 2. Suggested indexes to add 3. Expected performance improvement 4. Any trade-offs to consider
Need Claude AI Prompts (Not CLI)?
Looking for prompts for Claude's web interface or API? Check our complete guide with 100+ templates.
Supercharge Your Claude Code Workflow
Save all 40+ templates to your library. Organize by project, customize for your stack, and access anywhere.
About This Guide
Created by the AI Prompt Library team for Claude Code users. We maintain 10,000+ prompts for every AI tool and workflow.