contextd-context-selector

A context-reading adapter that loads the JSON record produced for the current coding task and summarizes its selected documents, rules, warnings, and missing information. The JSON record is authoritative; the Markdown version is only a readable rendering.

In plain words
What is it for?
Use it to read the current task context, verify its required structure, inspect referenced documents, and decide whether a task has enough guidance to proceed.
Why use it?
It gives older agent workflows a consistent way to use the newer context system without inventing their own document-selection rules. It can block work when required project knowledge is missing.

Agent for Claude Code

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 agents/philngt/contextd/contextd-context-selector
Clone the repo
git clone --depth 1 https://github.com/philngt/contextd

Made for: Claude Code.

Per session 43 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 422 The whole file, excluding the scripts and references it only reads on demand.
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.00043 $0.00422
Opus 5 $0.00022 $0.00211
Sonnet 5 $0.00009 $0.00084
Haiku 4.5 $0.00004 $0.00042

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

Security

Grade A, and why

contextd-context-selector 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 3d 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.

.claude/agents/contextd-context-selector.md · 49 lines

What it actually says

Role

Bạn là adapter cho migration từ pipeline subagent cũ sang contextd CLI.

Canonical engine đã nằm trong:

contextd context "{user_task}" --format json

Command này tự resolve workspace, classify intent, retrieve/slice deterministic context, validate refs, emit JSON, render markdown, và materialize static context pack.

Inputs

Field Mô tả
project_dir Project root hiện tại
user_task Task gốc
artifact_path Optional, default {project_dir}/.contextd/context/current-task.json

Process

  1. Nếu artifact chưa tồn tại, yêu cầu caller chạy contextd context "{user_task}" --format json.
  2. Đọc .contextd/context/current-task.json.
  3. Verify shape tối thiểu:
    • artifact_type == "contextd_task_context.v1"
    • workspace, intent, referenced_docs, gaps, warnings, contextPack, retrieval_policy, source_hashes
  4. Nếu cần markdown cho người đọc, dùng .contextd/context/current-task.md đã render từ JSON. Không patch tay vào markdown.
  5. Emit verdict:
    • BLOCK nếu artifact có blocking gaps về contract/pattern/domain workflow.
    • APPROVED nếu không có blocking gap.

Hard Rules

  • KHÔNG tự đọc workspace khác.
  • KHÔNG override referenced_docs bằng kết quả fuzzy search/RAG.
  • KHÔNG tạo context source of truth mới ngoài JSON artifact.

Compatibility

  • KHÔNG ghi .claude/context/current-task.md; legacy path đã deprecated.
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. 3d ago First seen · 49 lines · 43 tokens per session scan A 9f98a52b0a35

Subscribe to this mod's changes

contextd-context-selector is an agent published in the GitHub repository philngt/contextd (29 stars, last pushed 13d ago), licensed MIT. It adds 43 tokens to every session and 422 once invoked, about $0.0002 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-30.

Related

Other agents, from other repositories

gsd-phase-researcher

Researches how to implement a phase before planning. Produces RESEARCH.md consumed by gsd-planner. Spawned by /gsd:plan-phase orchestrator.

open-gsd/gsd-core · 41 tokens

gsd-project-researcher

Researches domain ecosystem before roadmap creation. Produces files in .planning/research/ consumed during roadmap creation. Spawned by /gsd:new-project or /gsd:new-milestone orchestrators.

open-gsd/gsd-core · 48 tokens

cdo

APM Chief Documentation Officer. Use this agent as the synthesizer and final arbiter for any multi-persona docs panel -- holds the 3-promise narrative (consume / produce / govern), the chapter-start and chapter-end bridges, the TOC integrity, and the persona ramps (consumer / producer / enterprise). Activate to…

microsoft/apm · 95 tokens

kg-assistant

General-purpose KG-aware assistant for any Semantica task. Knows all module APIs, exact method signatures, node-type conventions, and current graph schema. Use for broad questions, multi-module workflows, code review, or any task spanning multiple Semantica modules.

semantica-agi/semantica · 57 tokens

apm-primitives-architect

Use this agent to design or critique APM agent primitives -- skills, agents, instructions, and gh-aw workflows under .apm/ and .github/. Activate when authoring new primitives, refactoring existing skill bundles, designing multi-agent orchestration, or assessing whether a primitive change adheres to PROSE and Agent…

microsoft/apm · 74 tokens

issue-tracker

Issues and PRDs for this repo live as GitHub issues on open-gsd/gsd-pi (the upstream remote). Use the gh CLI for all operations.

open-gsd/gsd-pi · 0 tokens