Efficiency Hacks
The developer who saves 10 minutes per task does not seem impressive. But across 30 tasks per day, that is 5 hours per week. These efficiency hacks are the small techniques that compound into massive productivity gains.
What You Will Walk Away With
Section titled “What You Will Walk Away With”- Context management techniques that keep sessions lean and fast
- Output format tricks for different workflows
- Shell aliases and functions that reduce keystrokes
- Patterns for avoiding common time sinks
Context Management
Section titled “Context Management”Clear Between Unrelated Tasks
Section titled “Clear Between Unrelated Tasks”The single biggest efficiency win is clearing context when switching tasks:
/rename payment-bug-investigation/clearStale context from a previous task makes every subsequent message more expensive (more tokens processed) and less accurate (Claude uses irrelevant context).
Targeted Compaction
Section titled “Targeted Compaction”When you need to stay in the same session but context is bloated:
/compact Keep: file paths I edited, test results, error traces. Remove: exploratory file reads, discussion about alternatives, my questions.Add Compaction Rules to CLAUDE.md
Section titled “Add Compaction Rules to CLAUDE.md”# Compact instructionsWhen compacting, preserve:- Test results and error output- File paths and code changes made- Key decisions and their rationale
Remove:- Exploratory file reads that did not lead to changes- Verbose command output that has been summarized- Discussion of rejected approachesShell Aliases and Functions
Section titled “Shell Aliases and Functions”Quick Claude Code Shortcuts
Section titled “Quick Claude Code Shortcuts”Add to ~/.zshrc or ~/.bashrc:
# Quick question -- ask Claude without starting a sessionalias cq='claude -p'
# Continue last sessionalias cc='claude -c'
# Review current changesalias cr='git diff | claude -p "Quick review: only flag CRITICAL and HIGH issues."'
# Explain a fileexplain() { claude -p "Explain what $1 does, its key functions, and how it fits into the project."}
# Generate tests for a filegentest() { claude -p "Generate comprehensive tests for $1. Follow existing test patterns in this project."}
# Debug an errordebug() { echo "$@" | claude -p "Analyze this error and suggest a fix. Read the relevant source files."}Output Format Tricks
Section titled “Output Format Tricks”JSON for Script Consumption
Section titled “JSON for Script Consumption”When you need structured output:
claude -p "List all API endpoints with their HTTP method, path, and handler file" \ --output-format json | jq '.result'Structured Output with JSON Schema
Section titled “Structured Output with JSON Schema”For guaranteed output structure:
claude -p "Analyze the test coverage of src/api/" \ --json-schema '{"type":"object","properties":{"total_files":{"type":"number"},"covered_files":{"type":"number"},"uncovered_files":{"type":"array","items":{"type":"string"}}}}'Common Time Sinks and How to Avoid Them
Section titled “Common Time Sinks and How to Avoid Them””Let Me Read Everything First”
Section titled “”Let Me Read Everything First””Claude’s default behavior is to read many files before acting. For focused tasks, constrain the scope:
Fix the null pointer in src/api/users.ts line 42.Only read src/api/users.ts and its direct imports.Do not explore other files.“Let Me Summarize What I Did”
Section titled ““Let Me Summarize What I Did””Claude often spends tokens summarizing changes after making them. Add to your CLAUDE.md:
After making changes, do not provide a summary unless I ask for one.Instead, just show the git diff of what changed.Running Full Test Suites After Every Change
Section titled “Running Full Test Suites After Every Change”# In CLAUDE.mdWhen running tests after a change, run only the tests related to the modified file.Use: npx jest [file] --no-coverageOnly run the full test suite when I ask for it or before committing.Reading Package-Lock or Generated Files
Section titled “Reading Package-Lock or Generated Files”# In CLAUDE.mdNever read these files:- package-lock.json- yarn.lock- any file in dist/ or build/- any file in node_modules/- any .map fileQuick Wins
Section titled “Quick Wins”Use --add-dir for Multi-Repo Work
Section titled “Use --add-dir for Multi-Repo Work”# Work on a frontend app with access to the shared libraryclaude --add-dir ../shared-componentsFallback Model for Overloaded Periods
Section titled “Fallback Model for Overloaded Periods”claude -p "Quick task" --fallback-model sonnetIf Opus is overloaded, this automatically falls back to Sonnet instead of failing.
PR-Linked Sessions
Section titled “PR-Linked Sessions”# Create a session linked to a PRclaude --from-pr 123This loads context from the PR, making it easy to address review comments.
When This Breaks
Section titled “When This Breaks”Aliases conflict with other tools: Check for name conflicts with which cq before adding aliases. Choose unique names that do not shadow existing commands.
Context gets cleared accidentally: Get in the habit of using /rename before /clear. Sessions persist even after clearing, so you can resume them later.
Efficiency rules in CLAUDE.md are too restrictive: If Claude seems unable to explore when needed, use “ignore efficiency rules for this task” to override temporarily. The rules are guidance, not hard blocks.
What is Next
Section titled “What is Next”- Terminal Mastery — Deeper terminal optimization
- Monitoring and Costs — Track the impact of your efficiency improvements
- Setup and Configuration Tips — More configuration optimizations