ah AGENTS.md

Repository instructions for ah, a Rust command-line tool that searches and organizes past coding-agent sessions, including their transcripts and project details.

In plain words
What is it for?
Use it when developing ah’s commands, configuration, agent integrations, full-text search, memory and instruction listing, project summaries, or output formats.
Why use it?
It explains how session collection, filtering, searching, sorting, and agent-specific metadata work, reducing the risk of changing the wrong part of the tool.

Instructions file for CodexOpenCode

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add instructions/nihen/ah/agents-md
Clone the repo
git clone --depth 1 https://github.com/nihen/ah

Made for: Codex, OpenCode.

Per session 1,094 This file is loaded in full into every session.
When invoked 1,094 The same file — it is already loaded in full.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.01094 $0.01094
Opus 5 $0.00547 $0.00547
Sonnet 5 $0.00219 $0.00219
Haiku 4.5 $0.00109 $0.00109

Measured 2d ago against content hash fa5ad84cd31f, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

ah AGENTS.md scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

AGENTS.md · 99 lines

How it starts

The opening of the file, as written. The whole thing — 99 lines — stays where its author put it; the contents beside it link to each section on GitHub.

ah - Agent History

Cross-agent session search CLI written in Rust.

Build & Install

make install                    # local build + install

After changing code, always run make install to update the binary.

Architecture

src/
  main.rs        -- entry point: clap subcommand dispatch + agent/list-* commands
  cli.rs         -- clap derive CLI definition (Cli, Commands, FilterArgs, ProjectField) + help text
  config.rs      -- ~/.ahrc (TOML) parsing, agent registry (OnceLock<Vec<AgentDef>>)
  agents/        -- built-in agent plugins + registry + shared helpers
  session.rs     -- Session struct
  collector.rs   -- glob expansion + rayon parallel stat + BinaryHeap top-N
  pipeline.rs    -- unified session pipeline: collect → filter → search → resolve → sort
  projects.rs    -- project aggregation (shared by `ah project` and `ah project -i`)
  resolver.rs    -- plugin-driven metadata extraction and transcript shaping
  search.rs      -- mmap+regex full-text / plugin prompt-only search
  memory.rs      -- `ah memory` subcommand: memory + instruction file listing
  output.rs      -- TSV/LTSV/JSON output for log, project, and memory listing
  color.rs       -- color mode detection (--color/--no-color/TTY auto)
  pager.rs       -- auto-pager (less) setup for TTY output
  show.rs        -- `ah show` subcommand: pretty-print transcript + --follow
  resume.rs      -- `ah resume` subcommand: exec agent resume command
  man.rs         -- `ah man` subcommand: man page generation via clap_mangen
  remote.rs      -- `--remote` SSH aggregation: fetch from remote hosts, parse JSON, merge
  fuzzy.rs       -- `-i` interactive browse via fzf/sk for log, project, memory
  subcmd.rs      -- shared session resolver (stdin pipe, session ID/path, query, filters)

Key Design Decisions

  • No external tools for search/parsing (all indexing and query logic in-process; no rg/jq/sed)
    • Exception: --remote uses SSH to run ah on remote hosts (computation near data)
  • Parallel stat + metadata resolution via rayon
  • memmap2 for searching large JSONL files without copying
  • Plugin-internal regex compiled once via LazyLock; user query regex compiled per invocation
  • Single-pass filter_map for search filtering + metadata resolution
  • Default cwd filtering: all subcommands filter by current directory, -a for global
    • Exception: project defaults to all (no cwd filter)
  • Global options via Cli struct flatten, not per-subcommand
  • log, ah project, and ah memory share the same output system (TSV/LTSV/JSON, -f field selection) but use separate Field enums (Field for log, ProjectField for projects, MemoryField for memory) Field selection via -o/--fields and -O/--extra-fields

Read the full file on GitHub · 99 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 99 lines · 1,094 tokens per session scan A fa5ad84cd31f

Subscribe to this mod's changes

ah AGENTS.md is an instructions file published in the GitHub repository nihen/ah (2 stars, last pushed 12d ago), licensed MIT. It adds 1,094 tokens to every session, about $0.0055 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.