Host: Codex CLI — This skill was designed for Claude Code and adapted for Codex.
Cross-reference commands use installed skill names in Codex rather than /octo:* slash commands.
Use the active Codex shell and subagent tools. Do not claim a provider, model, or host subagent is available until the current session exposes it.
For host tool equivalents, see skills/blocks/codex-host-adapter.md.
Context Detection - Internal Skill
Purpose
This skill provides automatic context detection to determine whether the user is working in a Development context (code-focused) or Knowledge context (research/strategy-focused). This replaces the manual /octo:km toggle with intelligent auto-detection.
Detection Algorithm
When a workflow skill activates, detect context using these signals:
Step 1: Check for Explicit Override
If user has explicitly set mode via /octo:km on or /octo:km off, respect that setting.
# Check if knowledge mode is explicitly set
if [[ -f ~/.claude-octopus/config/knowledge-mode ]]; then
EXPLICIT_MODE=$(cat ~/.claude-octopus/config/knowledge-mode)
if [[ "$EXPLICIT_MODE" == "on" ]]; then
echo "knowledge"
exit 0
elif [[ "$EXPLICIT_MODE" == "off" ]]; then
echo "dev"
exit 0
fi
fi
# If "auto" or not set, proceed with auto-detection
Step 2: Analyze Prompt Content (Strongest Signal)
Knowledge Context Indicators (check prompt for these terms):
- Business/strategy: "market", "ROI", "stakeholders", "strategy", "business case", "competitive"
- Research: "literature", "synthesis", "academic", "papers", "research question"
- UX: "personas", "user research", "journey map", "pain points", "interviews"
- Deliverables: "presentation", "report", "PRD", "proposal", "executive summary"
Dev Context Indicators (check prompt for these terms):
- Technical: "API", "endpoint", "database", "function", "class", "module"
- Actions: "implement", "debug", "refactor", "test", "deploy", "build"
- Artifacts: "code", "tests", "migration", "schema", "controller"
Scoring:
- Count knowledge indicators in prompt
- Count dev indicators in prompt
- Higher count wins
- If tied, check project context (Step 3)
Step 3: Analyze Project Context (Secondary Signal)
Dev Project Indicators:
- Has
package.json, Cargo.toml, go.mod, pyproject.toml, pom.xml
- Has
src/, lib/, app/ directories with code files
- Recent files are
.ts, .js, .py, .go, .rs, .java
Knowledge Project Indicators:
- Has
docs/, research/, strategy/, reports/ directories
- Majority of files are
.md, .docx, .pdf, .pptx
- No code package managers detected
Step 4: Default Fallback
If signals are ambiguous or equal:
- In a git repo with code files → Default to Dev Context
- No code files detected → Default to Knowledge Context
Context Output Format
Return detected context as a structured object for use by workflow skills:
{
"context": "dev" | "knowledge",
"confidence": "high" | "medium" | "low",
"signals": {
"prompt_indicators": ["API", "endpoint", "database"],
"project_type": "node_typescript",
"explicit_override": false
}
}
How Workflow Skills Use Context
flow-discover (Research)
| Aspect |
Dev Context |
Knowledge Context |
| Research Focus |
Technical implementation, library comparison, code patterns |
Market analysis, academic synthesis, competitive research |
| Primary Agents |
Codex (implementation), Antigravity (ecosystem) |
Antigravity (analysis), research-synthesizer |
| Output Format |
Code examples, API comparisons, tech recommendations |
Reports, frameworks, strategic recommendations |
| Visual Banner |
🔍 [Dev] Discover Phase: Technical research |
🔍 [Knowledge] Discover Phase: Strategic research |
flow-develop (Build)
| Aspect |
Dev Context |
Knowledge Context |
| Build Focus |
Code generation, implementation, architecture |
PRDs, strategy docs, presentations |
| Primary Agents |
Codex (code), backend-architect, tdd-orchestrator |
product-writer, strategy-analyst, exec-communicator |
| Output Format |
Source files, tests, migrations |
Documents, frameworks, action plans |
| Visual Banner |
🛠️ [Dev] Develop Phase: Building code |
🛠️ [Knowledge] Develop Phase: Building deliverables |
flow-deliver (Review)
| Aspect |
Dev Context |
Knowledge Context |
| Review Focus |
Code quality, security, performance |
Document quality, argument strength, completeness |
| Primary Agents |
code-reviewer, security-auditor |
exec-communicator, strategy-analyst |
| Quality Gates |
OWASP, test coverage, maintainability |
Evidence quality, clarity, actionability |
| Visual Banner |
✅ [Dev] Deliver Phase: Code review |
✅ [Knowledge] Deliver Phase: Document review |
Visual Indicator Update
When context is detected, update the visual banner to show context:
Dev Context:
🐙 **CLAUDE OCTOPUS ACTIVATED** - Multi-provider research mode
🔍 [Dev] Discover Phase: Researching OAuth implementation patterns
Providers:
🔴 Codex CLI - Technical implementation analysis
🟡 Antigravity CLI - Ecosystem and library comparison
🔵 Claude - Strategic synthesis
Knowledge Context:
🐙 **CLAUDE OCTOPUS ACTIVATED** - Multi-provider research mode
🔍 [Knowledge] Discover Phase: Researching market entry strategies
Providers:
🔴 Codex CLI - Data analysis and modeling
🟡 Antigravity CLI - Market and competitive research
🔵 Claude - Strategic synthesis
Implementation in Workflow Skills
Each flow skill should:
- Before executing workflow, run context detection
- Show detected context in visual banner
- Adjust behavior based on context:
- Agent selection
- Prompt framing for external CLIs
- Output format expectations
- Quality gate criteria
Example Integration (Pseudocode)
When this skill activates:
1. **Detect context**
- Analyze user's prompt for knowledge vs dev indicators
- Check project type (code repo vs doc-heavy)
- Check for explicit override (~/.claude-octopus/config/knowledge-mode)
- Determine: "dev" or "knowledge" with confidence level
2. **Show context-aware banner**
🐙 CLAUDE OCTOPUS ACTIVATED - Multi-provider [research|implementation|validation] mode
[Phase Emoji] [Context] [Phase Name]: [Description]
Detected Context: [Dev|Knowledge] (confidence: [high|medium|low])
3. **Execute workflow with context-appropriate behavior**
- Frame prompts for external providers based on context
- Select appropriate synthesis approach
- Apply context-specific quality gates
Override Mechanism
Users can still explicitly set context when auto-detection is wrong:
# Force knowledge mode
/octo:km on
# Force dev mode
/octo:km off
# Return to auto-detection
/octo:km auto
When explicit override is set, context detection respects it until user resets to "auto".
Confidence Levels
- High: Strong signals in prompt AND project context agree
- Medium: Signals in prompt OR project context (not both)
- Low: Ambiguous signals, using fallback default
When confidence is "low", consider briefly mentioning the detected context to user:
"I detected this as a [dev/knowledge] task. If that's wrong, you can use /octo:km to override."
Testing Context Detection
To verify context detection is working:
- In a code repository, ask "octo research caching patterns" → Should detect Dev Context
- In same repo, ask "octo research market opportunities" → Should detect Knowledge Context
- With
/octo:km on set, ask "octo research API patterns" → Should use Knowledge Context (explicit override)
Proactive Skill Suggestions
When detecting the user's work stage, surface relevant command suggestions:
| Detected Context |
Suggestion |
| Brainstorming / exploring ideas |
Consider /octo:brainstorm for structured ideation |
| Reviewing a plan or strategy |
Consider /octo:plan for strategic planning |
| Debugging errors or failures |
Consider /octo:debug for systematic investigation |
| Writing or running tests |
Consider /octo:tdd for test-driven development |
| Code review before merge |
Use Claude-native /review for ordinary review; suggest /octo:review for multi-AI escalation |
| Ready to deploy or ship |
Consider /octo:deliver for quality-gated delivery |
| Researching a topic |
Consider /octo:research for multi-source synthesis |
| Working on security |
Use Claude-native /security-review for ordinary security review; suggest /octo:security for escalated OWASP or adversarial audit |
Suggestion Format
Suggestions should be non-intrusive, appended as a brief note:
💡 Tip: You appear to be debugging — `/octo:debug` provides systematic investigation with multi-AI support.
Persistent Opt-Out
- If user says "stop suggesting" or "no more tips": set
OCTO_PROACTIVE_SUGGESTIONS=off in .claude-octopus/preferences.json
- If user says "be proactive" or "turn on tips": set
OCTO_PROACTIVE_SUGGESTIONS=on
- Check preference at suggestion time — never suggest when opted out
- Respect current mode: dev mode suggestions differ from knowledge work suggestions
Re-Enable Suggestions
Users who previously opted out can re-enable suggestions at any time:
- Say "be proactive", "turn on tips", or "enable suggestions"
- Manually edit
~/.claude-octopus/preferences.json and set OCTO_PROACTIVE_SUGGESTIONS to on
- Default state (no preference set) is suggestions enabled
Detection Signals
Detect work stage from:
- Recent tool usage (many Bash calls = likely implementing/debugging)
- File types being edited (.test.ts = testing, .md = documentation)
- Error patterns in recent output (stack traces = debugging)
- Git state (uncommitted changes = implementing, clean tree = ready to review/ship)
1---2name: skill-context-detection3description: Auto-detect work context (Dev vs Knowledge) — use to tailor workflows based on current task type4---5
6> **Host: Codex CLI** — This skill was designed for Claude Code and adapted for Codex.
7> Cross-reference commands use installed skill names in Codex rather than `/octo:*` slash commands.
8> Use the active Codex shell and subagent tools. Do not claim a provider, model, or host subagent is available until the current session exposes it.
9> For host tool equivalents, see `skills/blocks/codex-host-adapter.md`.
10
11
12# Context Detection - Internal Skill
13
14## Purpose
15
16This skill provides **automatic context detection** to determine whether the user is working in a **Development context** (code-focused) or **Knowledge context** (research/strategy-focused). This replaces the manual `/octo:km` toggle with intelligent auto-detection.
17
18## Detection Algorithm
19
20When a workflow skill activates, detect context using these signals:
21
22### Step 1: Check for Explicit Override
23
24If user has explicitly set mode via `/octo:km on` or `/octo:km off`, respect that setting.
25
26```bash
27# Check if knowledge mode is explicitly set
28if [[ -f ~/.claude-octopus/config/knowledge-mode ]]; then
29 EXPLICIT_MODE=$(cat ~/.claude-octopus/config/knowledge-mode)
30 if [[ "$EXPLICIT_MODE" == "on" ]]; then
31 echo "knowledge"
32 exit 0
33 elif [[ "$EXPLICIT_MODE" == "off" ]]; then
34 echo "dev"
35 exit 0
36 fi
37fi
38# If "auto" or not set, proceed with auto-detection
39```
40
41### Step 2: Analyze Prompt Content (Strongest Signal)
42
43**Knowledge Context Indicators** (check prompt for these terms):
44- Business/strategy: "market", "ROI", "stakeholders", "strategy", "business case", "competitive"
45- Research: "literature", "synthesis", "academic", "papers", "research question"
46- UX: "personas", "user research", "journey map", "pain points", "interviews"
47- Deliverables: "presentation", "report", "PRD", "proposal", "executive summary"
48
49**Dev Context Indicators** (check prompt for these terms):
50- Technical: "API", "endpoint", "database", "function", "class", "module"
51- Actions: "implement", "debug", "refactor", "test", "deploy", "build"
52- Artifacts: "code", "tests", "migration", "schema", "controller"
53
54**Scoring:**
55- Count knowledge indicators in prompt
56- Count dev indicators in prompt
57- Higher count wins
58- If tied, check project context (Step 3)
59
60### Step 3: Analyze Project Context (Secondary Signal)
61
62**Dev Project Indicators:**
63- Has `package.json`, `Cargo.toml`, `go.mod`, `pyproject.toml`, `pom.xml`
64- Has `src/`, `lib/`, `app/` directories with code files
65- Recent files are `.ts`, `.js`, `.py`, `.go`, `.rs`, `.java`
66
67**Knowledge Project Indicators:**
68- Has `docs/`, `research/`, `strategy/`, `reports/` directories
69- Majority of files are `.md`, `.docx`, `.pdf`, `.pptx`
70- No code package managers detected
71
72### Step 4: Default Fallback
73
74If signals are ambiguous or equal:
75- In a git repo with code files → Default to **Dev Context**
76- No code files detected → Default to **Knowledge Context**
77
78
79## Context Output Format
80
81Return detected context as a structured object for use by workflow skills:
82
83```json
84{
85 "context": "dev" | "knowledge",
86 "confidence": "high" | "medium" | "low",
87 "signals": {
88 "prompt_indicators": ["API", "endpoint", "database"],
89 "project_type": "node_typescript",
90 "explicit_override": false
91 }
92}
93```
94
95
96## How Workflow Skills Use Context
97
98### flow-discover (Research)
99
100| Aspect | Dev Context | Knowledge Context |
101|--------|-------------|-------------------|
102| **Research Focus** | Technical implementation, library comparison, code patterns | Market analysis, academic synthesis, competitive research |
103| **Primary Agents** | Codex (implementation), Antigravity (ecosystem) | Antigravity (analysis), research-synthesizer |
104| **Output Format** | Code examples, API comparisons, tech recommendations | Reports, frameworks, strategic recommendations |
105| **Visual Banner** | `🔍 [Dev] Discover Phase: Technical research` | `🔍 [Knowledge] Discover Phase: Strategic research` |
106
107### flow-develop (Build)
108
109| Aspect | Dev Context | Knowledge Context |
110|--------|-------------|-------------------|
111| **Build Focus** | Code generation, implementation, architecture | PRDs, strategy docs, presentations |
112| **Primary Agents** | Codex (code), backend-architect, tdd-orchestrator | product-writer, strategy-analyst, exec-communicator |
113| **Output Format** | Source files, tests, migrations | Documents, frameworks, action plans |
114| **Visual Banner** | `🛠️ [Dev] Develop Phase: Building code` | `🛠️ [Knowledge] Develop Phase: Building deliverables` |
115
116### flow-deliver (Review)
117
118| Aspect | Dev Context | Knowledge Context |
119|--------|-------------|-------------------|
120| **Review Focus** | Code quality, security, performance | Document quality, argument strength, completeness |
121| **Primary Agents** | code-reviewer, security-auditor | exec-communicator, strategy-analyst |
122| **Quality Gates** | OWASP, test coverage, maintainability | Evidence quality, clarity, actionability |
123| **Visual Banner** | `✅ [Dev] Deliver Phase: Code review` | `✅ [Knowledge] Deliver Phase: Document review` |
124
125
126## Visual Indicator Update
127
128When context is detected, update the visual banner to show context:
129
130**Dev Context:**
131```
132🐙 **CLAUDE OCTOPUS ACTIVATED** - Multi-provider research mode
133🔍 [Dev] Discover Phase: Researching OAuth implementation patterns
134
135Providers:
136🔴 Codex CLI - Technical implementation analysis
137🟡 Antigravity CLI - Ecosystem and library comparison
138🔵 Claude - Strategic synthesis
139```
140
141**Knowledge Context:**
142```
143🐙 **CLAUDE OCTOPUS ACTIVATED** - Multi-provider research mode
144🔍 [Knowledge] Discover Phase: Researching market entry strategies
145
146Providers:
147🔴 Codex CLI - Data analysis and modeling
148🟡 Antigravity CLI - Market and competitive research
149🔵 Claude - Strategic synthesis
150```
151
152
153## Implementation in Workflow Skills
154
155Each flow skill should:
156
1571. **Before executing workflow**, run context detection
1582. **Show detected context** in visual banner
1593. **Adjust behavior** based on context:
160 - Agent selection
161 - Prompt framing for external CLIs
162 - Output format expectations
163 - Quality gate criteria
164
165### Example Integration (Pseudocode)
166
167```markdown
168When this skill activates:
169
1701. **Detect context**
171 - Analyze user's prompt for knowledge vs dev indicators
172 - Check project type (code repo vs doc-heavy)
173 - Check for explicit override (~/.claude-octopus/config/knowledge-mode)
174 - Determine: "dev" or "knowledge" with confidence level
175
1762. **Show context-aware banner**
177 ```
178 🐙 **CLAUDE OCTOPUS ACTIVATED** - Multi-provider [research|implementation|validation] mode
179 [Phase Emoji] [Context] [Phase Name]: [Description]
180
181 Detected Context: [Dev|Knowledge] (confidence: [high|medium|low])
182 ```
183
1843. **Execute workflow with context-appropriate behavior**
185 - Frame prompts for external providers based on context
186 - Select appropriate synthesis approach
187 - Apply context-specific quality gates
188```
189
190
191## Override Mechanism
192
193Users can still explicitly set context when auto-detection is wrong:
194
195```bash
196# Force knowledge mode
197/octo:km on
198
199# Force dev mode
200/octo:km off
201
202# Return to auto-detection
203/octo:km auto
204```
205
206When explicit override is set, context detection respects it until user resets to "auto".
207
208
209## Confidence Levels
210
211- **High**: Strong signals in prompt AND project context agree
212- **Medium**: Signals in prompt OR project context (not both)
213- **Low**: Ambiguous signals, using fallback default
214
215When confidence is "low", consider briefly mentioning the detected context to user:
216> "I detected this as a [dev/knowledge] task. If that's wrong, you can use `/octo:km` to override."
217
218
219## Testing Context Detection
220
221To verify context detection is working:
222
2231. In a code repository, ask "octo research caching patterns" → Should detect **Dev Context**
2242. In same repo, ask "octo research market opportunities" → Should detect **Knowledge Context**
2253. With `/octo:km on` set, ask "octo research API patterns" → Should use **Knowledge Context** (explicit override)
226
227
228## Proactive Skill Suggestions
229
230When detecting the user's work stage, surface relevant command suggestions:
231
232| Detected Context | Suggestion |
233|-----------------|------------|
234| Brainstorming / exploring ideas | Consider `/octo:brainstorm` for structured ideation |
235| Reviewing a plan or strategy | Consider `/octo:plan` for strategic planning |
236| Debugging errors or failures | Consider `/octo:debug` for systematic investigation |
237| Writing or running tests | Consider `/octo:tdd` for test-driven development |
238| Code review before merge | Use Claude-native `/review` for ordinary review; suggest `/octo:review` for multi-AI escalation |
239| Ready to deploy or ship | Consider `/octo:deliver` for quality-gated delivery |
240| Researching a topic | Consider `/octo:research` for multi-source synthesis |
241| Working on security | Use Claude-native `/security-review` for ordinary security review; suggest `/octo:security` for escalated OWASP or adversarial audit |
242
243### Suggestion Format
244
245Suggestions should be non-intrusive, appended as a brief note:
246
247```
248💡 Tip: You appear to be debugging — `/octo:debug` provides systematic investigation with multi-AI support.
249```
250
251### Persistent Opt-Out
252
253- If user says "stop suggesting" or "no more tips": set `OCTO_PROACTIVE_SUGGESTIONS=off` in `.claude-octopus/preferences.json`
254- If user says "be proactive" or "turn on tips": set `OCTO_PROACTIVE_SUGGESTIONS=on`
255- Check preference at suggestion time — never suggest when opted out
256- Respect current mode: dev mode suggestions differ from knowledge work suggestions
257
258### Re-Enable Suggestions
259
260Users who previously opted out can re-enable suggestions at any time:
261- Say "be proactive", "turn on tips", or "enable suggestions"
262- Manually edit `~/.claude-octopus/preferences.json` and set `OCTO_PROACTIVE_SUGGESTIONS` to `on`
263- Default state (no preference set) is suggestions enabled
264
265### Detection Signals
266
267Detect work stage from:
268- Recent tool usage (many Bash calls = likely implementing/debugging)
269- File types being edited (.test.ts = testing, .md = documentation)
270- Error patterns in recent output (stack traces = debugging)
271- Git state (uncommitted changes = implementing, clean tree = ready to review/ship)