Claude Code¶
← Voltar para AI Tools | 🏠 Home
Command-line AI assistant for development workflows
Claude Code is Anthropic's official CLI tool that brings Claude's capabilities directly to your terminal. It excels at file editing, code analysis, and terminal-based development tasks with deep understanding of codebases.
Claude Rules¶
-
First think through the problem, read the codebase for relevant files, and write a plan to tasks/todo.md.
-
The plan should have a list of todo items that you can check off as you complete them
-
Before you begin working, check in with me and I will verify the plan.
-
Then, begin working on the todo items, marking them as complete as you go.
-
Please every step of the way just give me a high level explanation of what changes you made
-
Make every task and code change you do as simple as possible. We want to avoid making any massive or complex changes. Every change should impact as little code as possible. Everything is about simplicity.
-
Finally, add a review section to the todo.md file with a summary of the changes you made and any other relevant information.
-
All resulting products (code, documentation, comments, variable names, etc.) must be written in English.
🎯 Why Claude Code?¶
- Direct file manipulation - Edit multiple files simultaneously
- Codebase understanding - Analyzes entire project contexts
- Terminal integration - Works seamlessly with existing workflows
- Multi-step tasks - Handles complex development workflows
- Git integration - Automated commit messages and PR creation
🔧 Installation & Setup¶
Prerequisites¶
- macOS or Linux (Windows support via WSL)
- Node.js 18+ (for some features)
- Git configured with your identity
Install Claude Code¶
# Install via npm (recommended)
npm install -g @anthropic-ai/claude-code
# Or via curl
curl -fsSL https://claude.ai/install.sh | sh
# Verify installation
claude --version
Authentication Setup¶
# Launch setup wizard
claude auth
# Or set API key manually
export ANTHROPIC_API_KEY="your-api-key-here"
🔍 Quick Verification¶
Test your Claude Code installation:
# Check version and auth status
claude --version
claude auth status
# Test basic functionality
claude "What's in this directory?" --files .
# Test file analysis
claude "Analyze this Python file for potential improvements" --files *.py
# Test with specific file
echo "def hello(): print('world')" > test.py
claude "Add docstring and type hints to this function" --files test.py
rm test.py
🚀 Core Features¶
File Analysis & Editing¶
# Analyze specific files
claude "Review this code for bugs" --files src/main.py
# Edit multiple files
claude "Add error handling to all functions" --files src/*.py
# Project-wide refactoring
claude "Rename variable 'data' to 'user_data' across the project" --files src/
Code Generation¶
# Generate new files
claude "Create a FastAPI endpoint for user authentication" --output src/auth.py
# Generate tests
claude "Create unit tests for the User class" --files src/models.py --output tests/test_user.py
# Generate documentation
claude "Create README with setup instructions" --files package.json --output README.md
Git Integration¶
# Automated commit messages
git add .
claude git commit
# Create pull request
claude git pr "Add user authentication feature"
# Analyze git diff
claude "Explain the changes in this diff" --git-diff
📋 Common Workflows¶
Code Review Process¶
- Stage your changes:
git add .
- Get AI review:
claude "Review these changes for issues" --git-diff
- Apply suggestions:
claude "Fix the issues you identified" --files src/
- Commit with AI message:
claude git commit
Bug Investigation¶
- Analyze error logs:
claude "Analyze this error" --files logs/error.log
- Review relevant code:
claude "Find potential causes" --files src/problematic_module.py
- Apply fixes:
claude "Fix the identified issues" --files src/
- Generate tests:
claude "Create tests to prevent this bug" --output tests/
Feature Development¶
- Plan architecture:
claude "Design a user authentication system"
- Generate scaffolding:
claude "Create the basic structure" --output src/auth/
- Implement features:
claude "Implement JWT authentication" --files src/auth/
- Add tests:
claude "Create comprehensive tests" --files src/auth/ --output tests/auth/
⚙️ Advanced Configuration¶
Project-Specific Setup¶
Create .claude.json
in your project root:
{
"include": ["src/**/*.py", "tests/**/*.py", "*.md"],
"exclude": ["venv/", "node_modules/", "*.pyc"],
"instructions": "Follow PEP 8 style guide. Use type hints. Write docstrings for all functions.",
"context_files": ["requirements.txt", "pyproject.toml"]
}
Custom Prompts¶
# Save frequently used prompts
claude config set-prompt "code-review" "Analyze this code for performance, security, and maintainability issues. Provide specific suggestions."
# Use saved prompts
claude code-review --files src/main.py
🔗 Integration Guides¶
- Development Workflows - End-to-end development patterns
- Prompting Patterns - Effective prompt strategies
- MCP Configurations - Model Context Protocol setups
- CI/CD Integration - Automated code review in pipelines
🐛 Troubleshooting¶
Common Issues¶
Authentication errors:
File permission issues:
# Check file permissions
ls -la problematic-file.py
# Fix permissions if needed
chmod 644 problematic-file.py
Context too large:
# Use specific files instead of directories
claude "task" --files specific-file.py
# Use .claude.json to exclude large files
📚 Related Documentation¶
- Claude Desktop - Desktop app for planning and architecture
- Git Workflows - Git integration patterns
- Python Development - Python-specific workflows
- VS Code Integration - Editor integration
🔐 Security Best Practices¶
- Never share API keys in prompts or commit them to repositories
- Review generated code before committing, especially security-related changes
- Use local models (Ollama) for proprietary or sensitive codebases
- Exclude sensitive files in
.claude.json
configuration - Audit AI-generated changes before deploying to production
Next: Start with Development Workflows to learn practical patterns, then explore Prompting Patterns for more effective AI interactions.