--- name: project-context-pack description: Use when the user wants a bounded repo context pack, project map, codebase index, or cached memory file so later work uses fd/rg/tree-sitter/LSP instead of repeated browsing. disable-model-invocation: true --- # Project Context Pack Create or refresh a bounded project memory file, then use it to navigate the codebase with discipline. ## Output target Default cache path: `.agent/project-context.md` at the project root. If the user names another path, use that path. If writing into the repo is risky or unexpected, ask before writing. Never write secrets into the cache. ## Procedure 1. **Find the root.** Prefer `git rev-parse --show-toplevel`; otherwise use `pwd`. Completion: you know the root and current relative working directory. 2. **Inventory cheaply.** Use `fd` and `rg` first; fall back to `find` and `grep`. Respect ignore files by default. Exclude `.git`, dependency directories, build outputs, caches, generated files, binaries, and large artifacts. Completion: you have a bounded file inventory and top-level tree without opening many files. 3. **Classify the project.** Detect language, framework, package manager, build/test tools, docs, agent guidance, and likely entry points from filenames and small config reads. Completion: the pack names the project type and the files that justify it. 4. **Read selectively.** Read only high-value files by default: README, agent guidance, package/build config, docs index, main entry points, and files directly relevant to the user's current request. Cap per-file and total content. Completion: every included file has a reason. 5. **Index symbols before browsing.** For code questions, prefer tree-sitter or LSP when available. Otherwise use `rg` patterns for definitions, exports, imports, routes, tests, commands, TODOs, and error strings. Completion: the pack has symbol/search notes before any broad source reading. 6. **Write the memory file.** Create or update the cache with the template below. Completion: the file exists and records when it was generated, commands/searches used, files inspected, and next navigation rules. 7. **Use the cache.** Before future exploration, read the cache first. If stale or insufficient, refresh the smallest relevant section instead of rebuilding everything. Completion: subsequent work cites the cache and avoids repeated file browsing. ## Navigation discipline - Do not wander file-by-file. Start with `fd`, `rg`, tree-sitter, LSP, or the cache. - Track inspected files in the memory file. - Prefer narrow searches over whole-file reads. - Prefer symbol outlines and matching snippets over full content. - Re-read a file only when it changed, the cache is stale, or the exact details are needed. - Ask before full-content extraction, large scans, or including sensitive files such as `.env`, credentials, private keys, tokens, browser profiles, or personal data. ## Useful command patterns ```bash root=$(git rev-parse --show-toplevel 2>/dev/null || pwd) cd "$root" # Inventory fd --type f --hidden --exclude .git 2>/dev/null || find . -type f -not -path './.git/*' tree -a -I '.git|node_modules|dist|build|target|.venv|__pycache__|vendor|coverage' -L 3 # Project signals fd '^(README|AGENTS|CLAUDE|GEMINI|package.json|pyproject.toml|Cargo.toml|go.mod|Makefile|justfile|docker-compose.yml)$' # Search before reading rg -n "TODO|FIXME|HACK|XXX" rg -n "^(export |class |def |function |interface |type |trait |struct |enum )" rg -n "main\(|if __name__ == .__main__.|export default|module.exports" ``` ## Memory file template ```markdown # Project Context Pack Generated: Root: Working directory: Status: ## Purpose ## Project type ## Structure ## Important files - — ## Commands - Build: - Test: - Lint/typecheck: - Run/dev: ## Entry points - — ## Search and symbol notes ## Files inspected - — — ## Exclusions ## Navigation rules for future agents ## Refresh notes ```