MCPInstall
ctxrs/ctx avatar

ctx-agent-history-search

Use ctx to search local coding-agent history before acting. Use when prior agent sessions may contain relevant insights, decisions, attempts, or transcript context.

Installs
202
Last 24h
—
Trending rank
—
Security
Not audited

Install

Works with every agent the skills CLI supports.

npx skills add https://github.com/ctxrs/ctx --skill ctx-agent-history-search
  1. 01

    Install

    Run the command in your project. The CLI asks which agents to install for.

  2. 02

    Describe the task

    Ask your agent for something this skill covers. It loads ctx-agent-history-search automatically when relevant.

  3. 03

    Review the result

    The agent follows the SKILL.md steps, scripts and references bundled with the skill.

SKILL.md

The instructions your agent reads when the skill is triggered.

ctx Agent History Search

Use ctx whenever you need to reference previous coding-agent sessions. Those transcripts can contain user intent, decisions, previous work timelines, past attempts, and what worked or failed.

Use this skill in two modes:

  • retrieval before work, when prior sessions may contain decisions, commands, failures, or citations that affect the current task;
  • history research reports, when the user asks an agent or read-only subagent to research a historical topic across prior local agent sessions.

Prerequisites

  • Require the ctx CLI to be installed and set up. If it is missing and installing tools is appropriate for the task, install it with:

    curl -fsSL https://ctx.rs/install | sh
    
  • First setup can take time while ctx indexes past sessions. If needed, keep it running in the background or in tmux, or wait for it to finish.

  • If ctx remains unavailable, say local history search is unavailable and do not invent results.

Workflow

  1. Confirm ctx is ready when starting from a cold context:

    ctx status
    ctx sources
    

    Use ctx status --format json or ctx sources --format json only when a script needs exact fields.

  2. Search with normal language first. Add terms or filters when useful:

    ctx search "<query>"
    ctx search "<query>" --refresh off
    ctx search "<query>" --provider codex
    ctx search "<query>" --workspace <workspace>
    ctx search "<query>" --file <path>
    ctx search "<query>" --since 30d
    ctx search "<query>" --term "<related term>" --term "<error text>"
    ctx search "<query>" --session <ctx-session-id>
    ctx search "<query>" --verbose
    

    Use default text output for agent reading. Do not add --format json for search or show unless you are piping it into jq or a script, or you need exact machine-readable fields. JSON output is much larger and can quickly consume the context window.

    When the prompt asks for a topic history or report across multiple sessions, run several ctx search queries with different wording and filters to find promising sessions. Use scoped ctx search "<query>" --session <ctx-session-id> when a session looks relevant and you need dense event-level matches from that session.

    Default search returns primary-agent sessions so human intent and decisions stay prominent. Use --include-subagents when implementation details, code review notes, test output, or failure traces from subagent sessions are likely to matter.

    Use --verbose when you need full ctx IDs, provider IDs, citations, and copyable follow-up commands without switching to JSON.

    You can write a session transcript to a temporary file, check the file size, and then read the relevant parts:

    ctx show session <ctx-session-id> --format markdown --out /tmp/ctx-session.md
    wc -c /tmp/ctx-session.md
    

    In Codex, ctx excludes the active session tree by default when CODEX_THREAD_ID is available, so the current prompt and subagents do not dominate historical retrieval. Use --include-current-session only when the active session tree is the target.

  3. Inspect relevant results before relying on them:

    ctx show event <ctx-event-id> --window 5
    ctx show session <ctx-session-id>
    
  4. Locate original provider material when source identity or resume hints matter. provider_session_id is the Codex resume UUID:

    ctx locate event <ctx-event-id>
    ctx locate session <ctx-session-id>
    
  5. Write a transcript of relevant sessions when you, the human, or another agent needs a file:

    ctx show session <ctx-session-id> --format markdown --out <output-path>
    

When Search Needs Narrowing

Vary the query and use search filters before drawing conclusions. Useful follow-ups include dense event search, session-scoped search, and source location checks:

ctx search "<query variant>" --events --refresh off
ctx search "<query>" --session <ctx-session-id> --refresh off
ctx search "<query>" --include-subagents --refresh off
ctx show event <ctx-event-id> --window 5
ctx show session <ctx-session-id>
ctx locate event <ctx-event-id>
ctx locate session <ctx-session-id>

Search result windows are bounded. Do not claim exact corpus-wide counts or a complete audit from the number of returned hits. If the requested conclusion cannot be supported with search, show, and locate evidence, state that limit and report the strongest retrieved evidence instead.

For advanced querying or complete deterministic event enumeration, use ctx list events. Read the full filter, range, cursor, and output documentation before use:

ctx docs show event-queries

History Research Reports

When asked to research a historical topic, stay read-only unless the user also asks for edits. The agent writes the report; ctx only retrieves local source material.

  1. Restate the topic, scope, and desired length if the prompt is ambiguous. Prefer concise reports by default; use a longer report when the user asks for chronology, alternatives, or detailed evidence.

  2. Run several targeted searches. Vary query terms across user wording, file or module names, error text, commands, branch names, and decision terms. Start with ctx search "<topic>", then broaden with --term or narrow with --workspace, --provider, --file, --since, or --session <ctx-session-id>. Use --include-subagents when reviews, implementation attempts, test output, or failure traces are likely to live in delegated sessions. Add --refresh off when the report must not update the local ctx index.

  3. Inspect focused sources before drawing conclusions. Prefer ctx show event for a hit plus nearby turns, and ctx show session when the whole session arc matters:

    ctx show event <ctx-event-id> --window 5
    ctx show session <ctx-session-id>
    

    Use full or log mode only when default output omits necessary evidence.

  4. Compare evidence across sessions. Note agreements, conflicts, stale results, and gaps where searches did not find evidence.

  5. Produce the report as agent synthesis with citations.

Concise report shape:

  • answer or finding;
  • strongest supporting ctx IDs;
  • important caveats or gaps;
  • optional next search or verification step.

Long report shape:

  • question and scope;
  • search method, including key queries and filters;
  • findings or chronology;
  • evidence table with provider, ctx session ID, ctx event ID when available, and why each source matters;
  • conflicts, gaps, and suggested follow-up.

Citation Rules

  • Cite ctx material when it affects your answer or implementation.
  • Include the provider, ctx session ID, ctx event ID when available, provider session ID when available.
  • If you synthesize across multiple snippets, label the conclusion as your synthesis and cite the supporting snippets.
  • If a cited event or session is absent from the current Core generation, say so and consider whether an explicit ctx import is appropriate.

Safety Rules

  • Prefer text output for agent reading. Use JSON only for scripts, jq, or exact field extraction, and keep JSON outputs small.
  • Do not say ctx inferred a decision unless the cited text explicitly states that decision.
  • Do not state that ctx wrote model analysis.
  • Do not paste raw transcripts, large JSON payloads, secrets, tokens, or private paths into a user-facing report. Summarize reviewed evidence and quote only short excerpts needed to support a claim.
  • Treat ~/.ctx, provider transcript paths, and JSON output as private local history unless the user explicitly asks to share reviewed excerpts.

FAQ

What does the ctx-agent-history-search skill do?

Use ctx to search local coding-agent history before acting. Use when prior agent sessions may contain relevant insights, decisions, attempts, or transcript context.

How do I install ctx-agent-history-search?

Run npx skills add https://github.com/ctxrs/ctx --skill ctx-agent-history-search in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/ctx-agent-history-search/ (personal) or .claude/skills/ctx-agent-history-search/ (project).

Which AI agents can use ctx-agent-history-search?

Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.

Is ctx-agent-history-search safe to install?

No partner security audit is available yet. Skills can run commands and scripts, so read the SKILL.md and any bundled files before installing.

Who maintains ctx-agent-history-search?

It is published by ctxrs/ctx in ctxrs/ctx. It has 202 recorded installs.

More from ctxrs/ctx

View all →
ctxrs avatar

ctx

ctxrs/ctx

Use ctx as working memory for prior agent work. Before starting or continuing work in an unfamiliar area, resuming earlier work, or revisiting an investigation, search prior sessions to ground yourself in earlier context. Use ctx blame to trace a line, file, commit, or PR to the agent session that produced it. Use when prior decisions, constraints, attempts, tool calls, transcript evidence, or code provenance may matter. Use ctx graph queries on indexed projects to follow calls and dependencies and understand what a change might affect.

Popular other skills

View category →
heygen-com avatar

hyperframes-cli

heygen-com/hyperframes

The HyperFrames CLI by job - scaffold, check, look at frames, edit the timeline, preview, render locally or in the cloud, publish, project history - plus reading its JSON and recovering from build or render failures.

1.7M installs
mattpocock avatar

triage

mattpocock/skills

Move issues and external PRs through a state machine of triage roles, categorise, verify, grill if needed, and write agent-ready briefs.

1.1M installs
mattpocock avatar

ask-matt

mattpocock/skills

Ask which skill or flow fits your situation. A router over the skills in this repo.

881.5K installs
mattpocock avatar

to-questionnaire

mattpocock/skills

Turn a decision you can't fully answer into a questionnaire for someone else to fill in.

609.4K installs
mattpocock avatar

wait-what

mattpocock/skills

Stop. That last message did not land: re-pitch it.

560.9K installs
mattpocock avatar

loop-me

mattpocock/skills

Grill me about specs for the workflows I want to build, within this workspace.

521.7K installs