Skip to content

Commit 97db63d

Browse files
cifrenLe Coq Francisclaude
authored
Add Claude Code cheatsheet with comprehensive command reference (#2190)
## Summary - Add new cheatsheet for Claude Code AI assistant CLI - Include most commonly used commands first for better UX - Cover interactive mode, file operations, git integration, and advanced features - Add comprehensive sections for workflows, troubleshooting, and best practices - Follow repository formatting conventions with proper YAML frontmatter ## Features Covered - ✅ Interactive mode and core commands - ✅ File operations and git integration - ✅ Advanced features (memory, image analysis) - ✅ Slash commands and productivity features - ✅ Common workflows (code review, testing, debugging) - ✅ IDE integrations and configuration - ✅ Troubleshooting and environment variables ## Test plan - [X] Verify YAML frontmatter follows repository conventions - [X] Check markdown formatting and table structure - [X] Ensure most used commands are prioritized at the top - [X] Validate all sections use proper Jekyll formatting classes - [X] Confirm links and references are accurate 🤖 Generated with [Claude Code](https://claude.ai/code) Co-authored-by: Le Coq Francis <[email protected]> Co-authored-by: Claude <[email protected]>
1 parent 01ee3a8 commit 97db63d

File tree

1 file changed

+383
-0
lines changed

1 file changed

+383
-0
lines changed

claude-code.md

Lines changed: 383 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,383 @@
1+
---
2+
title: Claude Code
3+
category: AI
4+
tags: [Featured]
5+
updated: 2025-01-08
6+
keywords:
7+
- AI assistant
8+
- CLI
9+
- Code generation
10+
- File operations
11+
- Interactive mode
12+
- Memory management
13+
---
14+
15+
## Getting started
16+
{: .-three-column}
17+
18+
### Introduction
19+
{: .-intro}
20+
21+
[Claude Code](https://claude.ai/code) is an AI-powered CLI assistant for software engineering tasks. This reference covers the most commonly used commands and features.
22+
23+
- [Claude Code docs](https://docs.anthropic.com/en/docs/claude-code) _(docs.anthropic.com)_
24+
- [GitHub repository](https://github.com/anthropics/claude-code) _(github.com)_
25+
26+
### Installation & Setup
27+
28+
```bash
29+
# Install Claude Code
30+
npm install -g @anthropics/claude-code
31+
32+
# Login with API key
33+
claude auth login
34+
35+
# Check authentication status
36+
claude auth status
37+
```
38+
39+
### Quick Start
40+
41+
```bash
42+
# Start interactive session
43+
claude
44+
45+
# Run a single command
46+
claude "help me write a Python function"
47+
48+
# Resume previous session
49+
claude --resume
50+
```
51+
52+
## Core Commands
53+
{: .-three-column}
54+
55+
### Interactive Mode
56+
{: .-prime}
57+
58+
| Command | Description |
59+
| -------------------------- | ---------------------------------- |
60+
| `claude` | Start interactive session |
61+
| `claude --resume` | Resume last session |
62+
| `claude --memory` | Start with memory enabled |
63+
| `/help` | Show help and available commands |
64+
| `/clear` | Clear current conversation |
65+
| `/exit` | Exit interactive mode |
66+
{: .-shortcuts}
67+
68+
### File Operations
69+
70+
| Command | Description |
71+
| -------------------------- | ---------------------------------- |
72+
| `claude "read file.py"` | Read and analyze a file |
73+
| `claude "edit file.py"` | Edit an existing file |
74+
| `claude "create file.py"` | Create a new file |
75+
| `claude "fix tests"` | Fix failing tests |
76+
| `claude "refactor code"` | Refactor existing code |
77+
{: .-shortcuts}
78+
79+
### Git Integration
80+
81+
| Command | Description |
82+
| ------------------------------- | ---------------------------------- |
83+
| `claude "create commit"` | Create git commit with message |
84+
| `claude "create PR"` | Create pull request |
85+
| `claude "review changes"` | Review git changes |
86+
| `claude "fix merge conflicts"` | Help resolve merge conflicts |
87+
{: .-shortcuts}
88+
89+
## Advanced Features
90+
{: .-three-column}
91+
92+
### Memory Management
93+
94+
```bash
95+
# Enable memory for current session
96+
claude --memory
97+
98+
# View memory contents
99+
claude "show memory"
100+
101+
# Clear memory
102+
claude "clear memory"
103+
```
104+
105+
### Extended Thinking
106+
107+
```bash
108+
# Enable deeper analysis
109+
claude --think
110+
111+
# Complex problem solving
112+
claude "analyze this codebase and suggest improvements"
113+
```
114+
115+
### Image Analysis
116+
117+
```bash
118+
# Analyze screenshot or diagram
119+
claude "analyze this screenshot" --image path/to/image.png
120+
121+
# Paste image from clipboard
122+
claude "explain this diagram" # then paste image
123+
```
124+
125+
## Slash Commands
126+
{: .-three-column}
127+
128+
### Session Management
129+
130+
| Command | Description |
131+
| ------------ | ------------------------------------ |
132+
| `/help` | Show available commands |
133+
| `/clear` | Clear conversation history |
134+
| `/reset` | Reset conversation state |
135+
| `/exit` | Exit interactive mode |
136+
| `/version` | Show Claude Code version |
137+
{: .-shortcuts}
138+
139+
### Settings
140+
141+
| Command | Description |
142+
| -------------- | ---------------------------------- |
143+
| `/settings` | Show current settings |
144+
| `/model` | Change AI model |
145+
| `/memory on` | Enable memory |
146+
| `/memory off` | Disable memory |
147+
{: .-shortcuts}
148+
149+
### Productivity
150+
151+
| Command | Description |
152+
| -------------- | ---------------------------------- |
153+
| `/save` | Save conversation |
154+
| `/load` | Load previous conversation |
155+
| `/export` | Export conversation to file |
156+
{: .-shortcuts}
157+
158+
## Common Workflows
159+
{: .-three-column}
160+
161+
### Code Review
162+
163+
```bash
164+
# Review specific file
165+
claude "review this code for bugs" file.py
166+
167+
# Review all changes
168+
claude "review my git changes"
169+
170+
# Check code quality
171+
claude "suggest improvements" src/
172+
```
173+
174+
### Testing
175+
176+
```bash
177+
# Generate tests
178+
claude "write tests for this function"
179+
180+
# Fix failing tests
181+
claude "fix these test failures"
182+
183+
# Test coverage analysis
184+
claude "analyze test coverage"
185+
```
186+
187+
### Documentation
188+
189+
```bash
190+
# Generate README
191+
claude "create README for this project"
192+
193+
# Add code comments
194+
claude "add documentation to this function"
195+
196+
# API documentation
197+
claude "generate API docs"
198+
```
199+
200+
### Debugging
201+
202+
```bash
203+
# Debug error
204+
claude "help debug this error: [error message]"
205+
206+
# Performance analysis
207+
claude "why is this code slow?"
208+
209+
# Code explanation
210+
claude "explain how this works" complex_function.py
211+
```
212+
213+
## IDE Integrations
214+
{: .-three-column}
215+
216+
### VS Code
217+
218+
```bash
219+
# Install VS Code extension
220+
code --install-extension anthropic.claude-code
221+
222+
# Open in VS Code
223+
claude --vscode
224+
225+
# VS Code commands
226+
Ctrl+Shift+P -> "Claude: Ask"
227+
Ctrl+Shift+P -> "Claude: Review"
228+
```
229+
230+
### Configuration
231+
232+
```bash
233+
# Set default editor
234+
claude config set editor code
235+
236+
# Set working directory
237+
claude config set workdir /path/to/project
238+
239+
# View all settings
240+
claude config list
241+
```
242+
243+
## Best Practices
244+
{: .-three-column}
245+
246+
### Effective Prompting
247+
248+
```bash
249+
# Be specific about requirements
250+
claude "write a Python function that validates email addresses with regex"
251+
252+
# Provide context
253+
claude "in this Django project, add user authentication"
254+
255+
# Ask for explanations
256+
claude "explain this code and suggest improvements"
257+
```
258+
259+
### Project Structure
260+
261+
```bash
262+
# Analyze entire project
263+
claude "analyze project structure and suggest improvements"
264+
265+
# Focus on specific areas
266+
claude "review the database models in models.py"
267+
268+
# Architecture decisions
269+
claude "should I use async here?"
270+
```
271+
272+
### Security
273+
274+
```bash
275+
# Security review
276+
claude "check this code for security vulnerabilities"
277+
278+
# Best practices
279+
claude "make this code more secure"
280+
281+
# Audit dependencies
282+
claude "review package.json for security issues"
283+
```
284+
285+
## CLI Options
286+
{: .-three-column}
287+
288+
### Global Options
289+
290+
| Option | Description |
291+
| ------------------- | ---------------------------------- |
292+
| `--help` | Show help information |
293+
| `--version` | Show version number |
294+
| `--resume` | Resume previous session |
295+
| `--memory` | Enable memory |
296+
| `--think` | Enable extended thinking |
297+
| `--no-color` | Disable colored output |
298+
| `--verbose` | Verbose logging |
299+
{: .-shortcuts}
300+
301+
### Authentication
302+
303+
| Command | Description |
304+
| -------------------- | ---------------------------------- |
305+
| `claude auth login` | Login with API key |
306+
| `claude auth logout` | Logout current session |
307+
| `claude auth status` | Check authentication status |
308+
| `claude auth whoami` | Show current user info |
309+
{: .-shortcuts}
310+
311+
### Configuration
312+
313+
| Command | Description |
314+
| ---------------------- | -------------------------------- |
315+
| `claude config set` | Set configuration value |
316+
| `claude config get` | Get configuration value |
317+
| `claude config list` | List all configuration |
318+
| `claude config reset` | Reset to default configuration |
319+
{: .-shortcuts}
320+
321+
## Troubleshooting
322+
{: .-three-column}
323+
324+
### Common Issues
325+
326+
```bash
327+
# Clear authentication
328+
claude auth logout && claude auth login
329+
330+
# Reset configuration
331+
claude config reset
332+
333+
# Clear cache
334+
claude --clear-cache
335+
336+
# Debug mode
337+
claude --verbose --debug
338+
```
339+
340+
### Network Issues
341+
342+
```bash
343+
# Check connectivity
344+
claude "test connection"
345+
346+
# Use proxy
347+
claude --proxy http://proxy:8080
348+
349+
# Timeout settings
350+
claude config set timeout 30
351+
```
352+
353+
### Memory Issues
354+
355+
```bash
356+
# Clear memory
357+
claude "clear memory"
358+
359+
# Disable memory
360+
claude --no-memory
361+
362+
# Memory usage
363+
claude "show memory usage"
364+
```
365+
366+
## Environment Variables
367+
368+
| Variable | Description |
369+
| --------------------- | ---------------------------------- |
370+
| `CLAUDE_API_KEY` | API key for authentication |
371+
| `CLAUDE_MODEL` | Default model to use |
372+
| `CLAUDE_MEMORY` | Enable memory by default |
373+
| `CLAUDE_EDITOR` | Default text editor |
374+
| `CLAUDE_WORKDIR` | Default working directory |
375+
| `NO_COLOR` | Disable colored output |
376+
377+
## Also see
378+
{: .-one-column}
379+
380+
- [Claude Code documentation](https://docs.anthropic.com/en/docs/claude-code) _(docs.anthropic.com)_
381+
- [GitHub repository](https://github.com/anthropics/claude-code) _(github.com)_
382+
- [Claude API docs](https://docs.anthropic.com/en/api) _(docs.anthropic.com)_
383+
- [Community discussions](https://github.com/anthropics/claude-code/discussions) _(github.com)_

0 commit comments

Comments
 (0)