name: oac:add-context description: Add context files from GitHub, worktrees, local files, or URLs to your project
Add context files to your project from various sources: $ARGUMENTS
The /oac:add-context command helps you add context files from:
This command invokes the context-manager subagent to:
/context-discoveryFormat: github:owner/repo[/path][#ref]
Examples:
# Add from GitHub repo (main branch)
/oac:add-context github:acme-corp/standards
# Add specific path
/oac:add-context github:acme-corp/standards/security
# Add specific branch/tag
/oac:add-context github:acme-corp/standards#v1.0.0
# Add with category
/oac:add-context github:acme-corp/standards --category=team
What it does:
Format: worktree:/path/to/worktree[/subdir]
Examples:
# Add from worktree
/oac:add-context worktree:../team-context
# Add specific subdirectory
/oac:add-context worktree:../team-context/standards
# Add with category
/oac:add-context worktree:../team-context/security --category=team
What it does:
Use case: Perfect for team members working on shared context in a separate worktree
Format: file:./path/to/file-or-dir
Examples:
# Add single file
/oac:add-context file:./docs/patterns/auth-flow.md
# Add directory
/oac:add-context file:./docs/patterns/
# Add with category and priority
/oac:add-context file:./docs/security.md --category=custom --priority=critical
What it does:
Use case: Add project-specific patterns or documentation to context
Format: url:https://example.com/path/to/file.md
Examples:
# Add from URL
/oac:add-context url:https://example.com/standards/security.md
# Add with category
/oac:add-context url:https://raw.githubusercontent.com/owner/repo/main/doc.md --category=external
What it does:
Use case: Add public documentation or standards from the web
--category=<name>Purpose: Specify target category for context files
Default: custom
Examples:
# Add to team category
/oac:add-context github:acme-corp/standards --category=team
# Add to custom category
/oac:add-context file:./docs/patterns.md --category=custom
# Add to core category (override defaults)
/oac:add-context file:./security.md --category=core
Categories:
core - Essential standards and workflowsteam - Team/company-specific contextcustom - Project-specific overridesexternal - External library documentationpersonal - Personal templates and patterns--priority=<level>Purpose: Set priority level for context files
Default: medium
Levels:
critical - Must-read files for all taskshigh - Strongly recommended filesmedium - Optional but helpful filesExamples:
# Mark as critical
/oac:add-context file:./security-policy.md --priority=critical
# Mark as high priority
/oac:add-context github:acme-corp/standards --priority=high
Impact: Priority affects ranking in /context-discovery results
--overwritePurpose: Overwrite existing files with same name
Default: false (skip existing files)
Examples:
# Overwrite existing files
/oac:add-context github:acme-corp/standards --overwrite
# Skip existing files (default)
/oac:add-context github:acme-corp/standards
Warning: Use with caution - overwrites local modifications
--dry-runPurpose: Preview what would be added without making changes
Examples:
# Preview GitHub addition
/oac:add-context github:acme-corp/standards --dry-run
# Preview worktree addition
/oac:add-context worktree:../team-context --dry-run
Output:
Dry Run: No changes will be made
Would add:
- security-patterns.md → .opencode/context/team/security-patterns.md
- auth-guidelines.md → .opencode/context/team/auth-guidelines.md
- deployment-process.md → .opencode/context/team/deployment-process.md
Would update:
- .opencode/context/team/navigation.md
- .opencode/context/navigation.md
Run without --dry-run to apply changes.
Command:
/oac:add-context github:acme-corp/engineering-standards/security --category=team --priority=critical
Process:
.opencode/contextacme-corp/engineering-standards (shallow)security/ directory.opencode/context/team/security/Output:
✅ Context root discovered: .opencode/context
✅ Cloned from GitHub: acme-corp/engineering-standards
Branch: main
Path: security/
✅ Validation passed:
- security-policies.md ✅
- auth-patterns.md ✅
- data-protection.md ✅
✅ Copied to: .opencode/context/team/security/
✅ Navigation updated:
- .opencode/context/team/navigation.md
- .opencode/context/navigation.md
✅ Verification: All files discoverable via /context-discovery
Summary:
- Added 3 context files to team/security/
- Source: github:acme-corp/engineering-standards/security
- Category: team
- Priority: critical
- Discoverable: ✅
Command:
/oac:add-context worktree:../team-context/standards --category=team
Process:
.claude/context (from .oac config)../team-context/standards/.claude/context/team/standards/Output:
✅ Context root discovered: .claude/context (from .oac config)
✅ Worktree validated: ../team-context/.git exists
✅ Copied from worktree: ../team-context/standards
Files: 5 markdown files
✅ Validation passed:
- code-quality.md ✅
- naming-conventions.md ✅
- testing-standards.md ✅
- deployment-process.md ✅
- review-checklist.md ✅
✅ Copied to: .claude/context/team/standards/
✅ Navigation updated:
- .claude/context/team/navigation.md
- .claude/context/navigation.md
✅ Verification: All files discoverable via /context-discovery
Summary:
- Added 5 context files to team/standards/
- Source: worktree:../team-context/standards
- Category: team
- Priority: medium (default)
- Discoverable: ✅
Command:
/oac:add-context file:./docs/patterns/auth-flow.md --category=custom --priority=high
Process:
context (found in project root)context/custom/patterns/Output:
✅ Context root discovered: context
✅ File validated: ./docs/patterns/auth-flow.md
Format: markdown ✅
Structure: valid ✅
Size: 2.3 KB
✅ Copied to: context/custom/patterns/auth-flow.md
✅ Navigation updated:
- context/custom/navigation.md
- context/navigation.md
✅ Verification: File discoverable via /context-discovery
Summary:
- Added 1 context file to custom/patterns/
- Source: file:./docs/patterns/auth-flow.md
- Category: custom
- Priority: high
- Discoverable: ✅
Command:
/oac:add-context url:https://raw.githubusercontent.com/openagents/standards/main/security.md --category=external --priority=critical
Process:
.opencode/context.opencode/context/external/Output:
✅ Context root discovered: .opencode/context
✅ Downloaded from URL: https://raw.githubusercontent.com/openagents/standards/main/security.md
Size: 5.2 KB
Content-Type: text/plain
✅ Validation passed:
- security.md ✅
✅ Saved to: .opencode/context/external/security.md
✅ Navigation updated:
- .opencode/context/external/navigation.md
- .opencode/context/navigation.md
✅ Verification: File discoverable via /context-discovery
Summary:
- Added 1 context file to external/
- Source: url:https://raw.githubusercontent.com/...
- Category: external
- Priority: critical
- Discoverable: ✅
Before adding context:
# Discover what context you need
/context-discovery authentication security patterns
# If context is missing, add it
/oac:add-context github:acme-corp/security-standards --category=team
After adding context:
# Context is now discoverable
/context-discovery authentication security patterns
# Returns newly added files:
# - .opencode/context/team/security-patterns.md ✅
After implementing a feature:
# Add learned patterns to context
/oac:add-context file:./docs/new-pattern.md --category=custom
# Now available for future tasks
# Add multiple sources
/oac:add-context github:acme-corp/standards --category=team
/oac:add-context worktree:../team-context --category=team
/oac:add-context file:./docs/patterns/ --category=custom
# Dry run to see what would be added
/oac:add-context github:acme-corp/standards --dry-run
# Review output, then add for real
/oac:add-context github:acme-corp/standards --category=team
# Overwrite existing files with latest from GitHub
/oac:add-context github:acme-corp/standards --category=team --overwrite
# Add from specific version
/oac:add-context github:acme-corp/standards#v2.0.0 --category=team
# Add from development branch
/oac:add-context github:acme-corp/standards#develop --category=team
The command automatically discovers where to add context:
Discovery Order:
context.root settingExample .oac config:
{
"context": {
"root": ".claude/context"
}
}
All added context files are validated:
Validation Output:
✅ Markdown format valid
✅ Structure valid (title, content)
⚠️ Metadata header missing (recommended but optional)
✅ Navigation entry added
Status: Valid (with warnings)
Cause: GitHub repo, worktree, or file doesn't exist
Solution:
# Verify GitHub repo exists
gh repo view acme-corp/standards
# Verify worktree exists
ls -la ../team-context/.git
# Verify local file exists
ls -la ./docs/patterns/auth-flow.md
Cause: File is not valid markdown or has structural issues
Solution:
Error: Validation failed for security-pattern.md
Issues:
❌ Not a markdown file (detected: text/html)
❌ Missing title (no # heading)
⚠️ No metadata header (recommended)
Fix these issues before adding to context.
Fix: Convert to markdown, add title, then retry
Cause: No context directory exists and .oac config missing
Solution:
# Option 1: Let command create default
/oac:add-context github:acme-corp/standards
# Creates .opencode/context automatically
# Option 2: Create .oac config
cat > .oac <<EOF
{
"context": {
"root": ".claude/context"
}
}
EOF
# Option 3: Create directory manually
mkdir -p .opencode/context
Cause: No write access to context directory
Solution:
# Check permissions
ls -la .opencode/
# Fix permissions
chmod -R u+w .opencode/context/
Cause: Navigation file is malformed or locked
Solution:
# Backup current navigation
cp .opencode/context/navigation.md .opencode/context/navigation.md.backup
# Let command regenerate navigation
/oac:add-context github:acme-corp/standards --category=team
/context-discovery after adding/oac:setup - Download OAC context from GitHub/oac:status - Check context installation status/oac:help - View all available commands/context-discovery - Discover added context files/context-manager - Manage context configuration/using-oac - Main workflow (uses added context)After running /oac:add-context, you should have:
/context-discoveryTest discoverability:
/context-discovery [topic related to added context]
# Should return newly added files
Version: 1.0.0
Command: oac:add-context
Last Updated: 2026-02-16