--- name: agent-context-skill description: Use when a coding agent needs project source context from Terrain agent assets. Guides Repomix pack retrieval on agent/repomix.md without loading the full pack. version: 1.2.0 --- # Agent Context Skill Terrain stores an **indexed source snapshot** at `.terrain/agent/repomix.md` in the repository, generated by **repomix-core** (`pack_strategy: architecture-context`). ## Design intent - **Authoritative source for Ask** — read code from the Repomix pack, not the live repository - **On index** — pack is generated automatically when a project is added and initialized - **Manual refresh** — user repacks via **重建源码索引** in the UI after major changes - **Low context cost** — grep and per-file reads; never dump the entire pack ## When to use - Answering questions about implementation, handlers, types, or routes - Locating entry points and module boundaries - Cross-file symbol search within the indexed snapshot ## Query strategy (mandatory order) 1. **Read meta** — `read_agent_pack_meta`: `synced_at`, `total_tokens`, `top_files_by_tokens`, `directory_structure`, `repo_path` 2. **Grep the pack** — `grep_agent_pack`: search for types, routes, module names, file paths 3. **Read file slices** — `read_agent_pack_file`: pull the matching `### path` section (optional line range) 4. **Never** — load all of `repomix.md` or read the live repo filesystem in Ask mode ## Terrain Tools (Ask mode) | Tool | Purpose | |------|------| | `read_agent_pack_meta` | Pack metrics, repo path, sync time | | `grep_agent_pack` | Regex search with context lines in repomix.md | | `read_agent_pack_file` | Read one file (or line range) from the pack | | `read_doc` | Human Litho docs under `human/` | | `search_knowledge` | Human + structured docs (not the agent pack) | ## Refresh Repack when `meta.synced_at` is stale or after major refactors (UI: **重建源码索引**, CLI: `terrain assets pack-agent `).