context-load-agents-context

Loads ancestor AGENTS.md context files for a target file with per-session deduplication.

Updated Jul 23, 2026
One-click install
npx skills add https://github.com/generic-automation-and-it/smooth-ai-stockanalysis --skill context-load-agents-context-generic-automation-and-it
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: context-load-agents-context
Source: https://github.com/generic-automation-and-it/smooth-ai-stockanalysis/tree/main/.agents/skills/context-load-agents-context
Command: npx skills add https://github.com/generic-automation-and-it/smooth-ai-stockanalysis --skill context-load-agents-context-generic-automation-and-it

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires jq, git, and includes scripts (resource) and references (resource) components.

What problem does it solve? AI coding agents often lack local domain context when reading or editing source files, and repeatedly injecting the same AGENTS.md files bloats the conversation. This Skill walks ancestor directories of a target file, emits each AGENTS.md at most once per session, and skips directories already auto-loaded by the AI tool. ## Core Features & Use Cases - Ancestor context walk: Finds AGENTS.md files from the target file's directory up to the git repository root, emitting them in a <context-auto-loaded> block. - Session deduplication: Canonicalizes physical paths and tracks loaded files per session so symlinked access (.claude/... vs .agents/...) never double-injects context. - Agent-agnostic invocation: Runs automatically as a Claude Code PostToolUse hook, or explicitly for Codex and Copilot with stable session identifiers. - Use Case: When an agent first edits src/SmoothAiStockAnalysis.Domain/Foo.cs, the hook injects the repo root and src/ AGENTS.md files once, giving the agent local conventions without manual prompting. ## Quick Start Ask the agent to load AGENTS context for the file you are about to edit, for example by invoking the skill with the target file path before making changes.

Frequently Asked Questions about context-load-agents-context

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I load AGENTS.md context for a file before editing it?▼

Run the script with the target file path: load-agents-context.sh --file path/to/source-file. It walks ancestor directories up to the git root and emits each AGENTS.md once per session inside a context-auto-loaded block.

How do I register this as a Claude Code PostToolUse hook?▼

Add a PostToolUse entry in .agents/settings.json with matcher "Read|Edit|Write" pointing to the hook wrapper at .agents/hooks/load-agents-context.sh. The wrapper execs the skill script, which always exits 0 so it never blocks the tool.

Does this work with Codex and GitHub Copilot?▼

Yes. Codex and Copilot invoke the script explicitly with --tool and a session identifier such as CODEX_SESSION_ID, CODEX_THREAD_ID, or COPILOT_SESSION_ID. These IDs drive stable per-session deduplication of injected files.

Why is the same AGENTS.md injected twice in one session?▼

Duplicate injection usually means the session ID changed between invocations or path canonicalization was bypassed. The script dedupes on physical paths via a tracker file in /tmp keyed by session ID, so keep the session identifier stable.

Which directories are skipped during context loading?▼

Files under .agents/rules/, .ai/rules/, .claude/rules/, .cursor/rules/, and .github/instructions/ are skipped because AI tools auto-load them. Re-emitting them would double their token cost in the conversation.