smith-ctx-claude
Claude Code context management with /compact and /clear commands, CLAUDE.md persistence, and Tool Search optimization. Use when operating in Claude Code IDE or when context exceeds 60%. Activate for context optimization in Claude sessions.
When & Why to Use This Skill
This Claude skill optimizes context management for Claude Code sessions, providing structured workflows for token reduction and session persistence. It enables developers to maintain high performance during long-running tasks by strategically compacting history, clearing unrelated context, and utilizing CLAUDE.md for persistent project guardrails.
Use Cases
- Optimizing long-running development sessions when context usage exceeds 60% by selectively retaining critical goals, architectural decisions, and specific file references.
- Switching between unrelated coding tasks by automating the workflow of committing changes and clearing the conversation history to prevent context pollution and hallucinations.
- Enforcing project-specific coding standards and architectural guardrails through persistent CLAUDE.md configuration that survives session resets.
- Reducing token consumption in large-scale projects by leveraging on-demand Tool Search optimization, achieving up to 85% reduction in tool-related overhead.
| name | smith-ctx-claude |
|---|---|
| description | Claude Code context management with /compact and /clear commands, CLAUDE.md persistence, and Tool Search optimization. Use when operating in Claude Code IDE or when context exceeds 60%. Activate for context optimization in Claude sessions. |
Claude Code Context Management
- Load if: Using Claude Code, context >60%
- Prerequisites: @smith-ctx/SKILL.md
CRITICAL: Context Commands (Primacy Zone)
Agent prompts for context status, then recommends action to user.
Thresholds: 60% warning, 70% critical, 90% emergency (see @smith-ctx/SKILL.md)
Decision tree:
- Same task, need space →
/compact keep [specifics] - New unrelated task → commit first, then
/clear
/compact - Selective Retention
Syntax: /compact keep [retention criteria]
Always specify what to keep:
- Task goals and requirements
- File paths with line numbers (file:line)
- Architectural decisions
- Incomplete todos/next steps
Recommendation format:
/compact keep task requirements, files (auth.ts:234, tokens.ts:89),
design decisions, remaining todos
- Claiming to execute
/compactdirectly (user must run it) - Vague criteria like "important stuff"
- Compacting away file:line references
- Compacting away incomplete work
/clear - Full Reset
Use when: Switching to unrelated task after committing work
Before /clear:
- Commit current work with detailed message
- Check for uncommitted changes
- Document session state
Preserved: Project files, CLAUDE.md Lost: All conversation history
/clearwithout checking uncommitted work/clearmid-task (use/compactinstead)/clearwhen context <90%
CLAUDE.md Persistence
Location: $WORKSPACE_ROOT/.claude/CLAUDE.md or $HOME/.claude/CLAUDE.md
Put in CLAUDE.md (always active):
- Critical guardrails (NEVER/ALWAYS)
- Reference to @AGENTS.md
- Project-specific preferences
Put in skill files (context-triggered):
- Detailed technical guidelines
- Platform-specific patterns
Tool Search Tool
85% token reduction - tools loaded on-demand, not upfront.
- Rely on Tool Search for documentation
- Use specific tool names for better retrieval
- Don't request full tool documentation dumps
Skills Directory Integration
Enable skill discovery:
ln -sf $HOME/.smith $HOME/.claude/skills
Claude Code discovers skills matching your tasks and asks before loading.
All skills prefixed with "smith-" to avoid conflicts with 50+ built-in commands.
Claude Code Features
Unique capabilities:
- Web search for current information
- Browser automation for testing
- MCP server integration (including Serena)
- 200k token context window
- Tool Search for on-demand tool loading
Plugin Discovery
Available plugin commands:
/code-review- Automated PR review with 4 parallel agents/commit- Auto-commit with message generation/commit-push-pr- Full PR workflow/clean_gone- Branch cleanup
Check installed plugins: /plugins or cat ~/.claude/plugins/installed_plugins.json
Official marketplace: anthropics/claude-plugins-official
- @smith-ctx/SKILL.md - Universal context strategies
@smith-ctx-cursor/SKILL.md- Cursor IDE context@smith-ctx-kiro/SKILL.md- Kiro platform context@smith-prompts/SKILL.md- Prompt caching optimization
ACTION (Recency Zone)
Proactive context management:
- Prompt for context status
- At 60%: Recommend
/compactwith retention criteria - At 70%: Warn of degradation, prepare criteria urgently
- At 90%: Recommend
/clearor aggressive compaction
Agent RECOMMENDS - user executes the command.
Workflow:
- Periodically prompt for context usage percentage
- Prepare retention criteria before hitting limits
- Recommend action with specific criteria
- Commit frequently for session recovery