Commands Reference¶
ContextHarness provides slash commands for use within OpenCode and Claude Code.
Same Commands, Both Tools
All ContextHarness commands work identically in both OpenCode and Claude Code. The commands are defined in tool-specific directories but provide the same functionality.
Session Commands¶
| Command | Description | Example |
|---|---|---|
/ctx {name} | Create or switch to a session (creates git branch) | /ctx login-feature |
/contexts | List all sessions with status | /contexts |
/compact | Save current context to SESSION.md | /compact |
/ctx {name}¶
Creates or switches to a named session:
What it does:
- Creates
.context-harness/sessions/login-feature/SESSION.md(if new) - Creates
feature/login-featurebranch (ifghavailable) - Loads existing context if session exists
- Updates SESSION.md with GitHub Integration section
/contexts¶
Lists all available sessions with metadata:
Output:
📁 Available Sessions:
- login-feature (Last: 2025-12-04, Status: In Progress)
- TICKET-1234 (Last: 2025-12-03, Status: Completed)
- api-rate-limiting (Last: 2025-12-02, Status: Blocked)
/compact¶
Manually saves current context:
What it does:
- Invokes
@compaction-guidefor recommendations - Updates SESSION.md with current state
- Preserves decisions, file changes, documentation
Note
Automatic compaction happens every 2nd user interaction, so manual /compact is usually not needed.
GitHub Commands¶
| Command | Description | Example |
|---|---|---|
/issue | Create GitHub issue from current context | /issue |
/issue update | Add progress comment to linked issue | /issue update |
/pr | Create pull request for current branch | /pr |
/issue¶
Creates a GitHub issue from session context:
What it does:
- Gathers context from SESSION.md
- Creates issue with
gh issue create - Updates SESSION.md with issue link
/issue update¶
Adds a progress comment to the linked issue:
/pr¶
Creates a pull request:
What it does:
- Pushes current branch to origin
- Creates PR with
gh pr create - Links to related issue (if exists)
- Updates SESSION.md with PR link
Options:
/pr --draft # Create as draft PR
/pr --title "Custom" # Use custom title
/pr --base develop # Target different base branch
Analysis Commands¶
| Command | Description | Example |
|---|---|---|
/baseline | Analyze project and generate PROJECT-CONTEXT.md + AGENTS.md | /baseline |
/baseline --path | Analyze specific directory (monorepo support) | /baseline --path apps/frontend |
/baseline --full | Force full regeneration | /baseline --full |
/baseline¶
Analyzes your project structure:
What it does:
- Discovery: Analyzes directory structure, language, tools
- Question Generation: Creates 30-50 questions about the project
- Answer Generation: Answers questions using codebase analysis
- Skill Extraction: Identifies patterns for reusable skills
- Memory File Generation: Creates AI agent instructions
Output:
PROJECT-CONTEXT.md— Comprehensive project contextAGENTS.md— AI agent instructions (OpenCode rules file)
PROJECT-CONTEXT.md— Comprehensive project contextCLAUDE.md— AI agent instructions (Claude Code memory file)
/baseline --path¶
Analyzes a specific directory within a monorepo:
What it does:
- Scopes analysis to the target directory only
- Generates outputs in the target directory:
apps/frontend/PROJECT-CONTEXT.mdapps/frontend/AGENTS.md- Creates self-contained AGENTS.md (no inheritance from root)
Use cases:
- Monorepos with multiple projects (apps, packages, services)
- Polyglot repos where different directories use different languages
- Large repos where full analysis is too slow
Examples:
/baseline --path apps/frontend # Analyze frontend app
/baseline --path packages/shared # Analyze shared package
/baseline --path services/api # Analyze API service
# Combine with other flags
/baseline --path apps/web --skip-skills --verbose
/baseline --path packages/ui --agents-only
AGENTS.md vs CLAUDE.md Precedence
Both OpenCode and Claude Code read the nearest memory file in the directory tree. Per the AGENTS.md standard, nested files completely override root files (no merging). This is why /baseline --path generates self-contained memory files.
Git Repository Recommended
The --path flag uses git to find the repository root for shared skill placement. Skills are written to {repo_root}/.opencode/skill/ so they can be shared across all projects in a monorepo.
Without git: Skills are placed in the target directory instead, and skill references may need manual adjustment.
/baseline --full¶
Forces complete regeneration, ignoring existing context: