context-index-codex

Installs a PostToolUse hook for Codex CLI that indexes large tool outputs with a local Ollama model.

Updated May 13, 2026
One-click install
npx skills add https://github.com/onesmash/slm-as-harness --skill context-index-codex-onesmash
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: context-index-codex
Source: https://github.com/onesmash/slm-as-harness/tree/main/skills/context-index/context-index-codex
Command: npx skills add https://github.com/onesmash/slm-as-harness --skill context-index-codex-onesmash

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Large Bash and MCP tool outputs in Codex CLI consume excessive context tokens, degrading agent performance and inflating costs. This Skill installs a hook that intercepts oversized outputs, saves them to disk, and returns a compact summary plus chunk index instead of raw text, cutting token usage by roughly 70-80%. ## Core Features & Use Cases - PostToolUse Hook Installation: Configures ~/.codex/hooks.json and config.toml so Codex CLI intercepts Bash and mcp__* tool results automatically. - Local Semantic Indexing: Uses a local qwen3.5:4b model via Ollama to generate summaries and chunk tables without sending data to external services. - Fail-Open Design: Any error (Ollama down, model missing, timeout) causes the hook to exit cleanly so the original output passes through unchanged. - Use Case: A developer running find or log-analysis commands that produce thousands of lines gets a short summary with chunk references, then retrieves only the relevant line ranges with sed -n instead of flooding the context window. ## Quick Start Ask the agent to install the context-index hook for Codex CLI, including Ollama setup, the qwen3.5:4b model, hook scripts, and hooks.json configuration.

Frequently Asked Questions about context-index-codex

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I reduce token usage from large tool outputs in Codex CLI?▼

Install a PostToolUse hook that intercepts Bash and MCP tool results exceeding a token threshold, saves raw output to disk, and returns a summary with a chunk index. The agent then retrieves specific line ranges with sed instead of loading full output.

How to set up a PostToolUse hook in Codex CLI?▼

Place the hook script in ~/.codex/hooks/, register it under PostToolUse in ~/.codex/hooks.json with a matcher and timeout, then enable codex_hooks = true under [features] in ~/.codex/config.toml.

Does the context-index hook work without Ollama running?▼

Yes, the hook fails open by design. If Ollama is down, the model is missing, or a timeout occurs, the hook exits with code 0 and the original tool output passes through to the agent unchanged.

Which local model does the Codex output indexer use?▼

It uses qwen3.5:4b served locally through Ollama, which is roughly a 2GB download. The model can be changed by setting the INDEXER_MODEL environment variable in your shell profile.

Why is the WebSearch tool not indexed by the Codex hook?▼

This is a known limitation of Codex CLI: the PostToolUse hook does not fire for the built-in WebSearch tool. Only Bash and mcp__* tools are interceptable by the hook.

How do I troubleshoot a Codex hook that is not firing?▼

Confirm codex_hooks = true exists under [features] in ~/.codex/config.toml and that ~/.codex/hooks.json has a PostToolUse entry. Then run a large-output command and watch for the Indexing large output status message.