Skip to content

Instantly share code, notes, and snippets.

@szymdzum
Last active September 20, 2025 06:42
Show Gist options
  • Select an option

  • Save szymdzum/be47d90b9d03c5ee22bc830b01495865 to your computer and use it in GitHub Desktop.

Select an option

Save szymdzum/be47d90b9d03c5ee22bc830b01495865 to your computer and use it in GitHub Desktop.
claude

Claude Code Memory Management & Context Optimization Guide

How Claude Code Memory Works

Claude Code uses a simple but powerful file-based memory system centered around CLAUDE.md files. These are automatically loaded into context when Claude Code starts, providing persistent memory across sessions.

Memory File Hierarchy

~/Developer/
├── CLAUDE.md                    # Global project memory
├── Projects/
│   ├── my-app/
│   │   ├── CLAUDE.md           # Project-specific memory
│   │   ├── src/
│   │   │   └── CLAUDE.md       # Module-specific memory
│   │   └── tests/
│   │       └── CLAUDE.md       # Test-specific memory
│   └── api-service/
│       └── CLAUDE.md           # Another project's memory
└── ~/.claude/
    └── my-preferences.md        # Personal preferences (imported)

How it loads: Claude recursively reads CLAUDE.md files from your current directory up to (but not including) root /.

1. Setting Up Efficient Memory Structure

Project Root CLAUDE.md

Create ~/Developer/Projects/my-app/CLAUDE.md:

# My App - E-commerce Platform

## Tech Stack
- TypeScript 5.x with strict mode
- Node.js 20.x, Express 4.x
- PostgreSQL 15 with Prisma ORM
- Redis for caching and rate limiting

## Architecture Decisions
- Hexagonal architecture with clear boundaries
- Repository pattern for data access
- Use cases in `/src/usecases/`
- Domain models in `/src/domain/`

## Coding Standards
- NO classes unless absolutely necessary
- Prefer pure functions and const exports
- Use Zod for runtime validation
- Error handling: Result<T, E> pattern

## Common Commands
- `npm run dev` - Start with hot reload
- `npm run test:watch` - Run tests in watch mode
- `npm run db:migrate` - Apply migrations

## Key Files
- `/src/config/` - All env and config
- `/src/middleware/auth.ts` - JWT implementation
- `/docs/API.md` - API documentation

## Current Sprint Focus
- Implementing checkout flow
- Performance optimization for product search
- Adding Stripe payment integration

# Import personal preferences
@~/.claude/my-preferences.md

Personal Preferences File

Create ~/.claude/my-preferences.md:

# Personal Coding Preferences

## Communication Style
- Be direct and concise
- Skip explanations unless asked
- Focus on implementation

## Code Style
- TypeScript: Use type inference where obvious
- Prefer const arrow functions
- Use early returns for guard clauses
- Comments only for complex logic

## Git Workflow
- Conventional commits: feat/fix/chore
- Branch naming: feature/JIRA-1234-description
- Squash commits before merge

## Testing Approach
- Test behavior, not implementation
- Use test.each for similar scenarios
- Mock external dependencies

2. Quick Memory Addition During Sessions

Use the # character to add memories on the fly:

claude
> implement user authentication
> # Auth uses JWT with 24h expiry, refresh tokens in Redis with 7d expiry
> # Password hashing: bcrypt with 10 rounds
> # Rate limit: 5 login attempts per 15 minutes per IP

Claude will prompt you to choose which memory file to save to.

3. Token-Optimized Memory Strategies

Strategy 1: Hierarchical Context Loading

Structure memories by specificity:

CLAUDE.md (root) - 200 tokens - General project info
├── src/CLAUDE.md - 150 tokens - Source code conventions
├── tests/CLAUDE.md - 100 tokens - Testing patterns
└── docs/CLAUDE.md - 50 tokens - Documentation style

Token Savings: Only relevant memories load based on working directory.

Strategy 2: Import-Based Composition

Instead of one large CLAUDE.md:

# Main CLAUDE.md - Keep minimal
## Project: E-commerce API

For detailed information:
@docs/architecture.md - System design
@docs/api-patterns.md - API conventions
@docs/database.md - Schema and queries
@docs/testing.md - Test strategies

Token Savings: ~60% reduction by loading only needed docs.

Strategy 3: Dynamic Memory Templates

Create task-specific memory files:

.claude/memory-templates/feature.md

# Feature: $FEATURE_NAME

## Requirements
- [ ] $REQUIREMENT_1
- [ ] $REQUIREMENT_2

## Technical Approach
- 

## Files to Modify
- 

## Test Scenarios
- 

## Edge Cases
- 

Use during development:

# Copy template when starting new feature
cp .claude/memory-templates/feature.md .claude/current-feature.md
# Edit and import in CLAUDE.md
echo "@.claude/current-feature.md" >> CLAUDE.md

4. Memory Optimization Patterns

Pattern 1: Decision Log

# Architectural Decisions

## 2024-12-15: Chose PostgreSQL over MongoDB
- Reason: Strong consistency requirements
- Impact: Use Prisma for type-safe queries

## 2024-12-10: Adopted Result<T,E> pattern
- Reason: Explicit error handling
- Example: `Result<User, AuthError>`
- Location: `/src/lib/result.ts`

Why it works: Provides context without implementation details.

Pattern 2: Code Patterns Library

# Common Patterns

## Service Pattern
```typescript
export const createUserService = (deps: Dependencies) => ({
  async createUser(data: CreateUserDto): Result<User, Error> {
    // validation → business logic → persistence
  }
})

Repository Pattern

export const userRepository = {
  async findById(id: string): Promise<User | null> {
    return prisma.user.findUnique({ where: { id } })
  }
}

**Token Savings**: Reference patterns instead of explaining each time.

### Pattern 3: Context Bridges

For complex features, create temporary context files:

```markdown
# Current Context: Payment Integration

## What's Done
- ✓ Stripe SDK integrated
- ✓ Webhook endpoint created
- ✓ Payment intent creation

## Current Task
- Implementing webhook signature verification

## Blockers
- Need to update CSP headers for Stripe.js

## Next Steps
- Add idempotency keys
- Implement retry logic

5. Reusing Memory Effectively

Create Semantic Shortcuts

In CLAUDE.md:

## Shortcuts
- "standard auth" = JWT + refresh tokens + rate limiting
- "api pattern" = validate → use case → repository → response
- "test pattern" = arrange → act → assert with test.each

Usage:

claude
> implement login endpoint using standard auth and api pattern

Build Command Memories

.claude/commands/implement-endpoint.md:

Implement a new API endpoint for $ARGUMENTS following these steps:
1. Check existing patterns in /src/routes/
2. Use standard validation with Zod
3. Implement use case in /src/usecases/
4. Add repository methods if needed
5. Write integration tests
6. Update API documentation

Follow the patterns in CLAUDE.md strictly.

Version Your Memories

# Before major refactoring
cp CLAUDE.md CLAUDE.md.backup-2024-12-15

# After refactoring
diff CLAUDE.md.backup-2024-12-15 CLAUDE.md > memory-changes.log

6. Advanced Memory Techniques

Technique 1: Contextual Imports

# CLAUDE.md
## Dynamic Imports Based on Task

Working on auth? @docs/auth-deep-dive.md
Working on payments? @docs/payment-flows.md
Working on search? @docs/search-architecture.md

Technique 2: Memory Compression

Use /compact to summarize long sessions into memory:

claude
> [long implementation session]
> /compact Create a summary focused on decisions made and patterns established
> # [Add the summary to CLAUDE.md]

Technique 3: Cross-Project Learning

Create ~/.claude/learned-patterns.md:

# Patterns That Worked Well

## From project-a
- Health check endpoint pattern
- Graceful shutdown implementation

## From project-b  
- Migration rollback strategy
- Circuit breaker pattern

## Anti-patterns to Avoid
- Mixing concerns in middleware
- Deeply nested callbacks

7. Memory Maintenance Workflow

Weekly Review Process

#!/bin/bash
# ~/Developer/Resources/scripts/memory-review.sh

echo "## Memory Review - $(date +%Y-%m-%d)" > memory-review.md

# Find all CLAUDE.md files modified this week
find . -name "CLAUDE.md" -mtime -7 -type f | while read file; do
  echo "\n### $file" >> memory-review.md
  git diff HEAD~7 -- "$file" | grep "^+" | grep -v "^+++" >> memory-review.md
done

# Review and consolidate
claude -p "Review these memory changes and suggest consolidations" < memory-review.md

Memory Metrics

Track memory effectiveness:

# Memory Usage Stats

## Token Count by File
- Root CLAUDE.md: 420 tokens
- src/CLAUDE.md: 280 tokens  
- tests/CLAUDE.md: 150 tokens
- Total: 850 tokens

## Most Referenced Sections
1. API Patterns (12 times this week)
2. Error Handling (8 times)
3. Test Strategies (6 times)

## Stale Sections (not referenced in 2 weeks)
- WebSocket implementation (removed)
- GraphQL notes (moved to archive)

Quick Reference

Essential Memory Commands

Action Method
Add memory during session Type # followed by content
Edit memory files /memory command
Import external file @path/to/file.md in CLAUDE.md
Check loaded memories First prompt asks Claude to list

Memory Best Practices

  1. Keep it concise: Each memory should be <100 tokens
  2. Use examples: Show patterns, don't just describe
  3. Stay current: Review and prune weekly
  4. Layer by specificity: General → Specific → Task
  5. Version control: Commit CLAUDE.md with code changes

Token Optimization Checklist

  • Root CLAUDE.md under 500 tokens
  • Use imports for detailed documentation
  • Remove outdated decisions/patterns
  • Consolidate similar patterns
  • Archive completed sprint notes
  • Use shortcuts for common patterns

Example: Complete Memory Setup

# 1. Initialize project memory
cd ~/Developer/Projects/new-app
claude
> /init
> # TypeScript strict mode, Node.js 20, PostgreSQL, Redis
> # Prefer functional style, no classes
> # Use Result<T,E> for error handling

# 2. Import personal preferences
echo "@~/.claude/my-preferences.md" >> CLAUDE.md

# 3. Create task-specific memory
echo "## Current Task: User Authentication" >> CLAUDE.md
echo "- [ ] JWT implementation" >> CLAUDE.md
echo "- [ ] Password reset flow" >> CLAUDE.md

# 4. Work and add learnings
> implement JWT auth
> # JWT secret from env.JWT_SECRET, 24h expiry
> # Refresh tokens in Redis, key: refresh:{userId}

# 5. Compress and archive
> /compact Focus on authentication decisions
git add CLAUDE.md && git commit -m "docs: Add auth implementation notes"

This approach ensures Claude always has the right context while minimizing token usage through strategic memory organization.

Claude Code: Jira Task Workflow - Token Optimized

Example Jira Task

PROJ-1234: Add rate limiting to user API endpoints
Priority: High
Description: Implement rate limiting for /api/users/* endpoints to prevent abuse.
Acceptance Criteria:
- 100 requests per minute per IP
- 1000 requests per hour per authenticated user  
- Return 429 status with retry-after header
- Add monitoring metrics
- Document in API docs

Pre-Task Setup (One-Time)

1. Create Reusable Commands

.claude/commands/jira-analyze.md

Analyze this Jira task: $ARGUMENTS

Output a concise plan with:
1. Key technical requirements (bullet points)
2. Files that need modification (list only)
3. Test scenarios needed (list only)
4. Potential issues to watch for

No code yet, just analysis. Be extremely concise.

.claude/commands/implement-plan.md

Based on the plan above, implement the changes:
1. Start with the core logic
2. Add error handling
3. Include TypeScript types
4. Follow existing patterns in codebase

Minimal explanations. Focus on code.

.claude/commands/test-endpoints.md

Create integration tests for these endpoints: $ARGUMENTS
Use existing test patterns from __tests__ directory.
Include: rate limit scenarios, edge cases, error conditions.
Output only test code.

~/.claude/commands/jira-commit.md

Create conventional commits for the current changes.
Read the git diff and create appropriate commits:
- Split by logical units
- Use format: type(scope): PROJ-$ARGUMENTS message
- Execute the commits
Brief output only.

2. Create Workflow Script

~/Developer/Resources/scripts/jira-start.sh

#!/bin/bash
set -euo pipefail

JIRA_ID=$1
JIRA_TITLE=$2

# Create feature branch
git checkout -b feature/${JIRA_ID}

# Create task context file
cat > .claude_task_context.md << EOF
Task: ${JIRA_ID}
Title: ${JIRA_TITLE}
Branch: feature/${JIRA_ID}
Started: $(date)
EOF

echo "Task ${JIRA_ID} initialized. Context saved."

Token-Optimized Workflow

Phase 1: Task Analysis (Planning First)

Tokens: ~500 (vs ~2000 for exploratory conversation)

# Initialize task
./jira-start.sh PROJ-1234 "Add rate limiting to user API endpoints"

# Copy task description to clipboard, then:
pbpaste | claude -p "/project:jira-analyze PROJ-1234" > task-plan.md

# Review the plan
cat task-plan.md

Output Example:

## Technical Requirements
- Redis for distributed rate limit tracking
- Middleware for Express routes
- 429 response with Retry-After header
- Prometheus metrics for monitoring

## Files to Modify
- src/middleware/rateLimiter.ts (create)
- src/routes/users.ts
- src/config/redis.ts
- src/metrics/index.ts
- tests/integration/users.test.ts

## Test Scenarios
- Under limit: 99 requests/minute
- At limit: 100th request
- Over limit: 101st request returns 429
- Header presence validation
- Redis failure fallback

## Watch For
- Redis connection failures
- Memory leaks in tracking
- Time window edge cases

Phase 2: Implementation Setup

Tokens: ~200

# Check existing patterns quickly
claude -p "grep -r 'middleware' src/ | head -10 && show me the middleware pattern used"

Phase 3: Core Implementation

Tokens: ~1500 (focused implementation)

# Start implementation with plan context
claude --continue << 'EOF'
cat task-plan.md
/project:implement-plan
implement Redis-based rate limiter middleware for the user API endpoints
focus on src/middleware/rateLimiter.ts first
EOF

Phase 4: Parallel Test Development

Tokens: ~800

In another terminal:

# Generate tests in parallel
claude -p "/project:test-endpoints /api/users/*" > new-tests.ts

# Review and apply
cat new-tests.ts >> src/__tests__/integration/users.test.ts

Phase 5: Quick Iterations

Tokens: ~300 per fix

# Run tests and fix issues efficiently
npm test -- users.test.ts 2>&1 | grep -A5 -B5 FAIL | claude -p "fix these specific test failures"

# Type checking
npx tsc --noEmit 2>&1 | claude -p "fix only these TypeScript errors"

Phase 6: Documentation Update

Tokens: ~400

# Update docs based on changes
git diff --name-only | grep -E '\.(ts|js)$' | \
  xargs claude -p "update API documentation for rate limiting based on these files"

Phase 7: Code Review Self-Check

Tokens: ~300

# Pre-PR review
git diff main | claude -p --output-format json "review for: security issues, edge cases, performance" | \
  jq -r '.issues[] | "[\(.severity)]: \(.file):\(.line) - \(.issue)"'

Phase 8: Commit and PR

Tokens: ~200

# Smart commits
claude
> /user:jira-commit 1234
> exit

# Generate PR description
git diff main --stat && git log main..HEAD --oneline | \
  claude -p "create PR description for PROJ-1234 rate limiting implementation"

Token Usage Breakdown

Phase Traditional Approach Optimized Approach Savings
Planning ~2000 (exploration) ~500 (structured) 1500
Implementation ~3000 (back-forth) ~1500 (focused) 1500
Testing ~1500 (iterative) ~800 (parallel) 700
Fixes ~1000 (verbose) ~300 (piped) 700
Documentation ~800 (manual) ~400 (automated) 400
Review ~600 (full context) ~300 (diff only) 300
Total ~8900 ~3800 ~5100 (57% reduction)

Advanced Optimizations

1. Task Template Generator

Create ~/.claude/commands/jira-template.md:

Generate a task-plan.md template for $ARGUMENTS that includes:
- Technical requirements checklist
- Affected files checklist  
- Test scenarios checklist
- Implementation order
Format as markdown checkboxes. No explanations.

2. Incremental Context Building

# Build context file incrementally
echo "## Current Context" > .context.md
echo "Task: PROJ-1234" >> .context.md
echo "### Decisions Made:" >> .context.md

# After each major decision
echo "- Using Redis for distributed rate limiting" >> .context.md

# Use context for focused queries
cat .context.md | claude -p "based on these decisions, implement the metrics collection"

3. Batch Similar Operations

# Find all files needing similar updates
grep -r "router\." src/ --include="*.ts" | cut -d: -f1 | sort -u > affected-routes.txt

# Batch update
cat affected-routes.txt | claude -p "add rate limiter middleware import to these route files"

Quick Reference: Jira Task Workflow

# 1. Start
./jira-start.sh PROJ-1234 "Title"

# 2. Analyze (paste Jira description)
pbpaste | claude -p "/project:jira-analyze PROJ-1234" > task-plan.md

# 3. Implement
claude < task-plan.md
> /project:implement-plan
> start with core rate limiter logic

# 4. Test (parallel terminal)
claude -p "/project:test-endpoints /api/users/*"

# 5. Fix issues (piped)
npm test 2>&1 | grep FAIL | claude -p "fix these"

# 6. Document
git diff --name-only | xargs claude -p "update docs"

# 7. Commit
claude
> /user:jira-commit 1234

# 8. PR
git diff main | claude -p "create PR description for PROJ-1234"

Key Principles

  1. Plan Before Code: Structured analysis saves thousands of tokens
  2. Use Piping: Direct error/diff input saves context tokens
  3. Parallelize: Run tests and implementation in separate sessions
  4. One-Shot Fixes: Use -p flag for single-purpose tasks
  5. Reuse Commands: Custom commands eliminate repetitive instructions
  6. Incremental Context: Build context file instead of conversation history

This workflow typically completes a Jira task in 3800-4000 tokens versus 8000-10000 tokens with conversational approach.

Claude Code Token Optimization & Workflow Guide

Core Principle: Maximum Output, Minimum Tokens

This guide shows how to configure Claude Code for efficiency using actual features from the CLI reference and slash commands documentation.

1. Token-Saving Configuration

Permission Pre-Configuration

Create ~/.claude/settings.json to avoid repetitive permission prompts:

{
  "permissions": {
    "allow": [
      "Edit(~/Developer/**)",
      "Read(~/Developer/**)",
      "Bash(git:*)",
      "Bash(npm:*)",
      "Bash(node:*)",
      "Bash(cat:*)",
      "Bash(ls:*)",
      "Bash(grep:*)",
      "WebFetch",
      "Grep",
      "Glob",
      "LS"
    ],
    "deny": [
      "Edit(~/.ssh/**)",
      "Bash(sudo:*)",
      "Bash(rm -rf:*)"
    ]
  }
}

Token Savings: Each permission prompt costs ~50-100 tokens. Pre-approving common operations saves thousands of tokens per session.

2. SDK Mode for One-Shot Tasks

Use -p flag for single operations to avoid conversational overhead:

# ❌ Inefficient (starts full REPL)
claude
> fix the typescript error in auth.ts
> exit

# ✅ Efficient (one-shot execution)
claude -p "fix the typescript error in auth.ts"

Piping for Context-Aware Operations

# Analyze specific output
npm test 2>&1 | claude -p "explain these test failures and fix them"

# Review specific changes
git diff | claude -p "review this code and suggest improvements"

# Parse logs efficiently
tail -n 100 error.log | claude -p "identify the root cause"

Token Savings: ~200-300 tokens per task by avoiding REPL overhead.

3. Custom Slash Commands Library

Project-Specific Commands

Create reusable commands in .claude/commands/:

.claude/commands/fix-type.md

Fix TypeScript type errors in $ARGUMENTS. 
Only modify type definitions, not implementation.
Be concise in explanations.

.claude/commands/test-quick.md

Write minimal test cases for $ARGUMENTS.
Use existing test patterns from the codebase.
No explanations, just code.

.claude/commands/snippet.md

Create a reusable TypeScript snippet for $ARGUMENTS.
Include: minimal JSDoc, type definitions, one usage example.
Save to ~/Developer/Snippets/typescript/.
Output only the code.

Personal Commands

Create in ~/.claude/commands/:

~/.claude/commands/commit-smart.md

git add -A && git status
Create a conventional commit message based on the changes.
Format: type(scope): description
Execute the commit.
No explanations needed.

~/.claude/commands/review-security.md

Review $ARGUMENTS for:
- Input validation gaps
- Auth bypasses
- Injection vulnerabilities
Output only actionable issues with line numbers.

Usage:

claude
> /project:fix-type auth.service.ts
> /user:commit-smart
> /project:test-quick calculateDiscount

Token Savings: 100-500 tokens per command by eliminating repetitive instructions.

4. Efficient Conversation Management

Use /compact Strategically

claude
> implement user authentication
> add password reset flow
> integrate email service
> /compact focus on auth implementation only

This compresses conversation history while maintaining context on what matters.

Clear When Context Isn't Needed

> /clear
> new task: optimize database queries

Token Savings: Up to 50% reduction in context tokens.

5. Smart Model Usage

For Max subscribers only:

# Start with default model for planning
claude
> outline the refactoring approach for the payment system

# Switch to Opus only for complex implementation
> /model opus
> implement the critical payment processing logic

# Switch back for documentation
> /model sonnet  
> document the changes

6. Batch Operations Workflow

Script Multiple Related Tasks

Create ~/Developer/Resources/scripts/batch-refactor.sh:

#!/bin/bash
set -euo pipefail

# Batch multiple operations in one session
claude --continue << 'EOF'
/project:fix-type src/services/*.ts
/project:test-quick calculateTax calculateDiscount processRefund
update the README with API changes
/user:commit-smart
EOF

Programmatic Usage with JSON Output

# Extract structured data efficiently
claude -p --output-format json "list all TODO comments with file paths" \
  | jq -r '.[] | "\(.file):\(.line) - \(.comment)"' \
  > todos.md

7. Project Initialization Optimization

Create Comprehensive CLAUDE.md

claude
> /init
> analyze the entire codebase structure and update CLAUDE.md with:
> - Key architectural decisions
> - Common code patterns used
> - Testing approach
> - Build and deployment process

This front-loads context, making future sessions more efficient.

8. Token-Efficient Workflows

Workflow 1: Quick Fix Workflow

# See the error
npm test

# Fix in one shot
npm test 2>&1 | tail -20 | claude -p "fix this specific test failure"

Workflow 2: Code Review Workflow

# Review changes without starting REPL
git diff main | claude -p --output-format json "review for issues" | jq -r '.issues[]'

Workflow 3: Documentation Update

# Generate docs from code changes
git diff --name-only | xargs claude -p "update docs for these changed files"

Workflow 4: Parallel Processing

# Use multiple terminals with --continue
# Terminal 1:
claude --continue
> refactor authentication module

# Terminal 2: 
claude --continue
> update test suite for new auth

# Terminal 3:
claude --continue  
> migrate database schema for auth changes

9. Advanced Token Optimization

Use --max-turns for Bounded Tasks

# Limit iterations to prevent token spiral
claude -p --max-turns 3 "debug and fix the memory leak"

Conditional Tool Permissions

# One-time dangerous operation with specific permission
claude -p --permission-prompt-tool "Bash(rm -rf node_modules)" "clean and reinstall dependencies"

Skip Permissions for Trusted Scripts

# For automated CI/CD - use with extreme caution
claude -p --dangerously-skip-permissions "run deployment checks"

10. Monitoring Token Usage

Track Costs

claude
> complete the feature
> /cost

Create Usage Report Script

#!/bin/bash
# ~/Developer/Resources/scripts/claude-usage.sh

echo "# Claude Code Usage Report - $(date +%Y-%m-%d)" > usage.md
echo "" >> usage.md

claude -p "/cost" --output-format json | jq -r '
  "## Token Summary\n" +
  "- Total: \(.total_tokens)\n" +
  "- Input: \(.input_tokens)\n" + 
  "- Output: \(.output_tokens)\n" +
  "- Estimated Cost: $\(.estimated_cost)\n"
' >> usage.md

Quick Reference Card

Most Efficient Patterns

Task Command Tokens Saved
One-shot fix claude -p "fix X" ~200
Piped analysis cmd | claude -p "analyze" ~300
Custom command /project:snippet ~150
Batch operations Script with --continue ~500
Quick review -p --output-format json ~250

Token Optimization Checklist

  • Pre-configure all common permissions
  • Use -p flag for single tasks
  • Create custom commands for repetitive tasks
  • Pipe context instead of copy-pasting
  • Use /compact to manage conversation size
  • Clear conversation when switching contexts
  • Initialize comprehensive CLAUDE.md
  • Monitor usage with /cost regularly

Example: Full Optimized Workflow

# 1. Morning setup (one-shot)
claude -p "check CLAUDE.md and summarize today's priorities"

# 2. Quick fixes (piped)
npm test 2>&1 | grep FAIL | claude -p "fix these failing tests"

# 3. Feature work (interactive with commands)
claude
> /project:snippet debounce function
> implement rate limiting for API endpoints
> /project:test-quick rateLimiter
> /compact
> /user:commit-smart

# 4. End of day (automated)
./claude-usage.sh
git diff --cached | claude -p "generate PR description" > pr.md

This workflow maximizes output while minimizing token usage through strategic use of Claude Code's actual features.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment