Claude Code di Terminal: Lebih dari Sekadar Chat AI
Claude Code dapat dijalankan langsung di terminal (tanpa VS Code atau IDE lainnya), dan memiliki shortcuts keyboard yang powerful untuk boost produktivitas. Kebanyakan developer tidak tahu bahwa Claude Code di terminal memiliki shortcuts sendiri yang berbeda dari shell shortcuts biasa.
Mengapa Pakai Claude Code di Terminal?
- ✅ Lightweight: Tidak butuh membuka VS Code atau IDE berat
- ✅ SSH-friendly: Bisa dipakai di remote servers via SSH
- ✅ Quick access: Instant help saat coding di terminal
- ✅ Context-aware: Auto-detect file, folder, dan terminal output sebagai context
Perbedaan dengan Shell Shortcuts Biasa
| Type | Shell Shortcuts (bash/zsh) | Claude Code Shortcuts |
|---|---|---|
| Scope | Edit command line | Interact dengan Claude AI |
| Example | Ctrl+W (delete word) | Cmd/Ctrl+K (clear chat) |
| Context | Current command only | Files, folders, history |
⚠️ Important: Artikel ini fokus ke shortcuts Claude Code saat dijalankan di terminal (via
claude-codecommand atau Claude Desktop app di terminal mode), bukan shell shortcuts biasa.
Setup: Install dan Jalankan Claude Code di Terminal
macOS Terminal Setup
# Install Claude Code CLI (if not installed)
brew install claude-code
# Or download from Anthropic
curl -fsSL https://install.anthropic.com/claude-code | sh
# Verify installation
claude-code --version
# Set API key (get from console.anthropic.com)
export ANTHROPIC_API_KEY="sk-ant-xxx"
# Add to ~/.zshrc untuk permanent
echo 'export ANTHROPIC_API_KEY="sk-ant-xxx"' >> ~/.zshrc
# Run Claude Code
claude-code
Windows Command Prompt / PowerShell Setup
# Install via Scoop (recommended)
scoop install claude-code
# Or via Chocolatey
choco install claude-code
# Verify installation
claude-code --version
# Set API key
setx ANTHROPIC_API_KEY "sk-ant-xxx"
# Run Claude Code
claude-code
Terminal Interface Overview
$ claude-code
╔════════════════════════════════════════╗
║ Claude Code Terminal ║
║ ║
║ Cmd/Ctrl+K - Clear conversation ║
║ Cmd/Ctrl+L - Show shortcuts ║
║ Cmd/Ctrl+Q - Quit ║
║ @file - Attach file ║
║ /explain - Explain code ║
╚════════════════════════════════════════╝
You: | # Cursor blinks di sini
💡 Pro Tip: Run
claude-code --helpuntuk see all available CLI options dan flags.
Keyboard Shortcuts Essential Claude Code
Navigation & Control Shortcuts
| Shortcut (macOS) | Shortcut (Windows) | Fungsi | Use Case |
|---|---|---|---|
Cmd + K |
Ctrl + K |
Clear Conversation | Start fresh conversation |
Cmd + L |
Ctrl + L |
Show Shortcuts List | Quick reference guide |
Cmd + Q |
Ctrl + Q |
Quit Claude Code | Exit to terminal |
Cmd + H |
Ctrl + H |
Show Conversation History | Previous conversations |
Cmd + N |
Ctrl + N |
New Conversation | Keep current, start new |
Esc |
Esc |
Cancel Generation | Stop Claude mid-response |
Input & Editing Shortcuts
| Shortcut (macOS) | Shortcut (Windows) | Fungsi | Use Case |
|---|---|---|---|
Cmd + V |
Ctrl + V |
Paste Code/Text | Paste error messages, code |
Cmd + C |
Ctrl + C |
Copy Claude Response | Copy code suggestions |
↑ / ↓ |
↑ / ↓ |
Navigate Message History | Reuse previous prompts |
Cmd + U |
Ctrl + U |
Clear Input | Delete entire input line |
Cmd + W |
Ctrl + W |
Delete Last Word | Quick word deletion |
Enter |
Enter |
Send Message | Submit prompt ke Claude |
Shift + Enter |
Shift + Enter |
New Line (Multi-line Input) | Untuk paste code blocks |
Response Interaction Shortcuts
| Shortcut (macOS) | Shortcut (Windows) | Fungsi | Use Case |
|---|---|---|---|
Cmd + Enter |
Ctrl + Enter |
Accept Code Suggestion | Auto-copy code ke clipboard |
Cmd + R |
Ctrl + R |
Regenerate Response | Get different answer |
Cmd + S |
Ctrl + S |
Save Response to File | Export ke .txt atau .md |
Cmd + D |
Ctrl + D |
Copy Code Block Only | Skip explanation text |
Cmd + E |
Ctrl + E |
Execute Code Suggestion | Run suggested command di shell |
💡 Power Shortcut:
Cmd/Ctrl+Enteradalah shortcut paling powerful! Setelah Claude kasih code suggestion, press ini untuk langsung copy ke clipboard—laluCmd/Ctrl+Vke editor atau run di terminal.
🔥 Quick Workflow: Ask question →
Enter→ read response →Cmd/Ctrl+Enter(accept) →Cmd/Ctrl+Q(quit) → paste code. Total: 3 detik!
Context Attachment dengan @-Mentions
Fitur paling powerful dari Claude Code di terminal adalah @-mentions untuk attach context. Ketik @ lalu Tab untuk auto-complete.
Jenis @-Mentions yang Tersedia
| Syntax | Fungsi | Example |
|---|---|---|
@file:path |
Attach specific file | @file:src/app.js explain this |
@folder:path |
Attach entire folder | @folder:src/models review structure |
@clipboard |
Attach clipboard content | @clipboard fix this error |
@last |
Attach last terminal output | @last why did this fail? |
@git:diff |
Attach git diff | @git:diff generate commit msg |
@cwd |
Attach current directory info | @cwd list all files and explain structure |
Cara Menggunakan @-Mentions di Terminal
# Attach single file
$ claude-code
You: @file:server.js explain the authentication logic
# Multiple files
You: @file:routes.js @file:middleware.js how do these work together?
# Folder analysis
You: @folder:src/auth review security of all auth files
# Clipboard (copy error terlebih dahulu dengan Cmd/Ctrl+C)
You: @clipboard this error happened, what's wrong?
# Last terminal output (after running command yang error)
$ npm test
# Error muncul...
$ claude-code
You: @last explain why tests failed
# Git diff untuk commit message
$ git add .
$ claude-code
You: @git:diff generate semantic commit message
# Current directory context
You: @cwd what kind of project is this? suggest improvements
Advanced: Multi-Context
# Scenario 1: Debug dengan full context
You: @file:app.js @last @clipboard
The error in clipboard happened after running command.
File context shows current code. What's the issue?
# Scenario 2: Code review
You: @folder:src/controllers @git:diff
Review changes in this PR. Check for:
- Security issues
- Performance problems
- Best practices violations
# Scenario 3: Project documentation
You: @cwd @file:package.json @file:README.md
Generate comprehensive setup guide for new developers
💡 Auto-complete Tip: Ketik
@laluTabuntuk show available contexts. Ketik@file:laluTab Tabuntuk list files di current directory.
🎯 Best Practice:
@lastadalah shortcut paling useful untuk debugging! Run command yang error →claude-code→@last explain error.
Slash Commands untuk Quick Actions
Slash commands adalah shorthand untuk common prompts. Ketik / lalu Tab untuk see all commands.
Daftar Slash Commands
| Command | Equivalent Prompt | Use Case |
|---|---|---|
/explain |
“Explain this code/error” | Understand complex logic |
/fix |
“Fix this bug/error” | Quick bug fixes |
/optimize |
“Optimize for performance” | Speed improvements |
/test |
“Generate unit tests” | Auto-create tests |
/doc |
“Add documentation” | Generate JSDoc/comments |
/review |
“Review code for issues” | Security & quality check |
/refactor |
“Refactor for clarity” | Clean up messy code |
/convert |
“Convert to language X” | JS→TS, Py→Go, etc |
/commit |
“Generate commit message” | Semantic git commits |
/cmd |
“Generate shell command” | Complex commands |
Contoh Penggunaan Slash Commands
# Scenario 1: Debug error
$ npm start
Error: Cannot find module 'express'
$ claude-code
You: @last /fix
Claude: The error indicates missing 'express' dependency.
Run: npm install express
[Code: npm install express]
# Cmd/Ctrl+Enter to accept
# Cmd/Ctrl+E to execute immediately
# Scenario 2: Generate tests
$ claude-code
You: @file:utils.js /test
Claude: Here are unit tests for utils.js:
```javascript
describe('utils', () => {
test('formatDate returns correct format', () => {
// test code...
});
});
```
# Cmd/Ctrl+D to copy code only
# Scenario 3: Git commit
$ git add .
$ claude-code
You: @git:diff /commit
Claude: feat(auth): add JWT authentication middleware
# Cmd/Ctrl+C to copy message
# Cmd/Ctrl+Q to quit
$ git commit -m "feat(auth): add JWT authentication middleware"
# Scenario 4: Generate command
$ claude-code
You: /cmd find all .log files larger than 100MB modified in last 7 days
Claude: find . -name "*.log" -size +100M -mtime -7 -ls
# Cmd/Ctrl+E to execute immediately
🔥 Power Combo:
@last + /fixadalah workflow tercepat untuk debugging! Run error command →claude-code→@last /fix→Cmd/Ctrl+E(execute fix).
Workflow Produktif di Terminal
Workflow 1: Quick Debugging (10 detik)
# Step 1: Run command (error muncul)
$ npm test
# Error: Test suite failed...
# Step 2: Ask Claude (2 detik)
$ claude-code
You: @last /fix
[Enter]
# Step 3: Execute fix (3 detik)
Claude: Run: npm install --save-dev jest
[Cmd/Ctrl+E] # Execute immediately
# Step 4: Quit (1 detik)
[Cmd/Ctrl+Q]
# Total: 10 detik (vs Googling: 5-10 menit)
Workflow 2: Code Review Before Commit
# Step 1: Check changes
$ git add .
$ git diff --cached
# Step 2: Review dengan Claude
$ claude-code
You: @git:diff /review
Check for:
- Security issues
- Performance problems
- Missing error handling
# Step 3: Fix issues jika ada
Claude: Found issue in auth.js line 23:
Password not hashed before saving.
You: @file:auth.js /fix add bcrypt hashing
# Step 4: Generate commit message
You: @git:diff /commit
Claude: feat(auth): add password hashing with bcrypt
[Cmd/Ctrl+C]
[Cmd/Ctrl+Q]
# Step 5: Commit
$ git commit -m "feat(auth): add password hashing with bcrypt"
Workflow 3: Generate & Test Command
# Step 1: Ask untuk complex command
$ claude-code
You: /cmd
Backup postgres database to /backup folder with:
- Timestamp in filename
- Gzip compression
- Keep last 7 days only
# Step 2: Claude generate command
Claude:
```bash
pg_dump mydb | gzip > /backup/db-$(date +%Y%m%d-%H%M%S).sql.gz && \
find /backup -name "db-*.sql.gz" -mtime +7 -delete
```
# Step 3: Test dengan dry-run
You: wrap that in echo for dry-run
Claude:
```bash
echo "Would backup to: /backup/db-$(date +%Y%m%d-%H%M%S).sql.gz" && \
find /backup -name "db-*.sql.gz" -mtime +7 -print
```
[Cmd/Ctrl+E] # Execute dry-run
# Step 4: Jika OK, execute real command
[↑] # Previous command
[backspace beberapa kali untuk edit]
[Enter]
Workflow 4: Multi-file Refactoring
# Step 1: Understand current structure
$ claude-code
You: @folder:src/auth review structure and suggest improvements
# Step 2: Plan refactoring
Claude: Suggestions:
1. Extract validation to separate file
2. Split large controller into smaller files
3. Add error handling middleware
You: start with #1, @file:src/auth/controller.js /refactor
Extract validation logic to validators.js
# Step 3: Generate new file
Claude: Create validators.js:
```javascript
// validation code...
```
[Cmd/Ctrl+S] # Save to file (prompt for filename)
# Enter: validators.js
# Step 4: Update original file
You: @file:src/auth/controller.js update to use validators.js
# Repeat untuk each refactoring step
💡 Pro Tip: Setup alias di
~/.zshrcatau~/.bashrcuntuk quick access:alias ask='claude-code' alias fix='claude-code --prompt "@last /fix"' alias explain='claude-code --prompt "@last /explain"' # Usage: $ npm test # Error $ fix # Auto-run claude with @last /fix
Kesimpulan & Cheat Sheet
Must-Know Shortcuts (Top 10)
| Shortcut | Fungsi | Frequency |
|---|---|---|
Cmd/Ctrl+Enter |
Accept suggestion | Every response ⭐⭐⭐⭐⭐ |
Cmd/Ctrl+Q |
Quit Claude | Every session ⭐⭐⭐⭐⭐ |
@last |
Last terminal output | Debugging ⭐⭐⭐⭐⭐ |
/fix |
Fix errors | Daily ⭐⭐⭐⭐ |
Cmd/Ctrl+E |
Execute code/command | Quick fixes ⭐⭐⭐⭐ |
@file:path |
Attach file context | Code review ⭐⭐⭐⭐ |
↑/↓ |
Message history | Reuse prompts ⭐⭐⭐ |
Cmd/Ctrl+K |
Clear conversation | Fresh start ⭐⭐⭐ |
Cmd/Ctrl+D |
Copy code only | Skip explanation ⭐⭐⭐ |
/commit |
Generate commit msg | Git workflow ⭐⭐⭐ |
Quick Reference Card (Print This)
═══════════════════════════════════════════
CLAUDE CODE TERMINAL SHORTCUTS
═══════════════════════════════════════════
NAVIGATION:
Cmd/Ctrl + Q → Quit
Cmd/Ctrl + K → Clear conversation
Cmd/Ctrl + H → History
Cmd/Ctrl + L → Show shortcuts
Esc → Cancel generation
INPUT:
Enter → Send message
Shift + Enter → New line (multi-line)
↑ / ↓ → Message history
Cmd/Ctrl + U → Clear input
Cmd/Ctrl + W → Delete word
RESPONSE:
Cmd/Ctrl + Enter → Accept suggestion (copy)
Cmd/Ctrl + E → Execute code/command
Cmd/Ctrl + D → Copy code only
Cmd/Ctrl + C → Copy full response
Cmd/Ctrl + R → Regenerate
Cmd/Ctrl + S → Save to file
CONTEXT (@):
@file:path → Attach file
@folder:path → Attach folder
@clipboard → Clipboard content
@last → Last terminal output
@git:diff → Git changes
@cwd → Current directory
ACTIONS (/):
/explain → Explain code
/fix → Fix errors
/optimize → Improve performance
/test → Generate tests
/doc → Add documentation
/review → Code review
/refactor → Clean code
/commit → Git commit message
/cmd → Generate shell command
POWER COMBOS:
@last + /fix → Debug errors (fastest!)
@file:x + /review → Code quality check
@git:diff + /commit → Semantic commits
@clipboard + /explain → Understand copied code
@folder:x + /refactor → Project cleanup
═══════════════════════════════════════════
Practice Plan (3 Days)
Day 1: Master basic shortcuts
- Practice:
claude-code→ ask question →Cmd/Ctrl+Enter→Cmd/Ctrl+Q - Repeat 20x sampai muscle memory
- Try
@lastuntuk debugging real errors
Day 2: Master context & commands
- Practice
@file:,@folder:,@clipboard - Try all slash commands:
/fix,/explain,/test,/review - Setup aliases di shell config
Day 3: Build workflows
- Create custom debugging workflow
- Setup git commit workflow dengan
/commit - Practice
Cmd/Ctrl+Euntuk execute suggestions
Productivity Impact
Developer yang master Claude Code terminal shortcuts report:
- ✅ 80% faster debugging –
@last /fixvs manual Googling (10 sec vs 5-10 min) - ✅ 5x faster commit messages –
@git:diff /commit(5 sec vs 2 min) - ✅ 90% less context switching – Stay in terminal, no browser needed
- ✅ 50% faster code reviews –
@file /reviewinstant feedback
Bottom line: 2-4 jam saved per day. ROI: 1-2 hari practice untuk lifetime productivity boost.

