Claude Code tutorials
Practical examples and patterns for effectively using Claude Code in your development workflow.
This guide provides step-by-step tutorials for common workflows with Claude Code. Each tutorial includes clear instructions, example commands, and best practices to help you get the most from Claude Code.
Table of contents
- Understand new codebases
- Fix bugs efficiently
- Refactor code
- Work with tests
- Create pull requests
- Handle documentation
- Use advanced git workflows
- Work with images
- Set up project memory
- Use Claude as a unix-style utility
- Set up Model Context Protocol (MCP)
Understand new codebases
Get a quick codebase overview
When to use: You’ve just joined a new project and need to understand its structure quickly.
Navigate to the project root directory
Start Claude Code
Ask for a high-level overview
Dive deeper into specific components
Tips:
- Start with broad questions, then narrow down to specific areas
- Ask about coding conventions and patterns used in the project
- Request a glossary of project-specific terms
Find relevant code
When to use: You need to locate code related to a specific feature or functionality.
Ask Claude to find relevant files
Get context on how components interact
Understand the execution flow
Tips:
- Be specific about what you’re looking for
- Use domain language from the project
Fix bugs efficiently
Diagnose error messages
When to use: You’ve encountered an error message and need to find and fix its source.
Share the error with Claude
Ask for fix recommendations
Apply the fix
Tips:
- Tell Claude the command to reproduce the issue and get a stack trace
- Mention any steps to reproduce the error
- Let Claude know if the error is intermittent or consistent
Refactor code
Modernize legacy code
When to use: You need to update old code to use modern patterns and practices.
Identify legacy code for refactoring
Get refactoring recommendations
Apply the changes safely
Verify the refactoring
Tips:
- Ask Claude to explain the benefits of the modern approach
- Request that changes maintain backward compatibility when needed
- Do refactoring in small, testable increments
Work with tests
Add test coverage
When to use: You need to add tests for uncovered code.
Identify untested code
Generate test scaffolding
Add meaningful test cases
Run and verify tests
Tips:
- Ask for tests that cover edge cases and error conditions
- Request both unit and integration tests when appropriate
- Have Claude explain the testing strategy
Create pull requests
Generate comprehensive PRs
When to use: You need to create a well-documented pull request for your changes.
Summarize your changes
Generate a PR with Claude
Review and refine
Add testing details
Tips:
- Ask Claude directly to make a PR for you
- Review Claude’s generated PR before submitting
- Ask Claude to highlight potential risks or considerations
Handle documentation
Generate code documentation
When to use: You need to add or update documentation for your code.
Identify undocumented code
Generate documentation
Review and enhance
Verify documentation
Tips:
- Specify the documentation style you want (JSDoc, docstrings, etc.)
- Ask for examples in the documentation
- Request documentation for public APIs, interfaces, and complex logic
Work with images
Analyze images and screenshots
When to use: You need to work with images in your codebase or get Claude’s help analyzing image content.
Add an image to the conversation
You can use any of these methods:
Ask Claude to analyze the image
Use images for context
Get code suggestions from visual content
Tips:
- Use images when text descriptions would be unclear or cumbersome
- Include screenshots of errors, UI designs, or diagrams for better context
- You can work with multiple images in a conversation
- Image analysis works with diagrams, screenshots, mockups, and more
Set up project memory
Create an effective CLAUDE.md file
When to use: You want to set up a CLAUDE.md file to store important project information, conventions, and frequently used commands.
Bootstrap a CLAUDE.md for your codebase
Tips:
- Include frequently used commands (build, test, lint) to avoid repeated searches
- Document code style preferences and naming conventions
- Add important architectural patterns specific to your project
- You can add CLAUDE.md files to the folder you run Claude in, parent directories (Claude reads these automatically), or child directories (Claude pulls these in on demand)
Use Claude as a unix-style utility
Add Claude to your verification process
When to use: You want to use Claude Code as a linter or code reviewer.
Steps:
Add Claude to your build script
Pipe in, pipe out
When to use: You want to pipe data into Claude, and get back data in a structured format.
Pipe data through Claude
Set up Model Context Protocol (MCP)
Model Context Protocol (MCP) is an open protocol that enables LLMs to access external tools and data sources. For more details, see the MCP documentation.
Use third party MCP servers at your own risk. Make sure you trust the MCP servers, and be especially careful when using MCP servers that talk to the internet, as these can expose you to prompt injection risk.
Configure MCP servers
When to use: You want to enhance Claude’s capabilities by connecting it to specialied tools and external servers using the Model Context Protocol.
Add an MCP Stdio Server
Manage your MCP servers
Tips:
- Use the
-s
or--scope
flag withproject
(default) orglobal
to specify where the configuration is stored - Set environment variables with
-e
or--env
flags (e.g.,-e KEY=value
) - MCP follows a client-server architecture where Claude Code (the client) can connect to multiple specialized servers
Connect to a Postgres MCP server
When to use: You want to give Claude read-only access to a PostgreSQL database for querying and schema inspection.
Add the Postgres MCP server
Query your database with Claude
Tips:
- The Postgres MCP server provides read-only access for safety
- Claude can help you explore database structure and run analytical queries
- You can use this to quickly understand database schemas in unfamiliar projects
- Make sure your connection string uses appropriate credentials with minimum required permissions
Next steps
Claude Code reference implementation
Clone our development container reference implementation.
Was this page helpful?