代理上下文加载器
- 作者仓库星标 2,235
- 作者仓库 claude-code-plugins-plus-skills
- 领域
- 效率工具
- 作者声明的智能体
- 未找到明确声明;不据此推断已兼容或已测试
- 静态检查
- 88 / 100 · 启发式扫描,不代表运行安全
- 运行环境证据
- 未执行;当前没有隔离运行测试证据
- 作者 / 版本 / 许可证
- @jeremylongshore · 未声明许可证
- 上下文用量评级
- 低消耗
- 接入复杂程度
- 即装即用
- 是否需要外部接口密钥
- 不需要
- 兼容的系统
- 未声明(默认跨平台)
- 运行环境要求
- 未检出明确要求
- 检测到的文件与系统行为
-
- 只读
- 允许写入 / 修改
- 网络行为
- 仅限本地
- 安装命令数
- 无(仅作为资料)
需要注意: 未声明工具权限范围;实际权限由运行环境决定。
# Agent Context Loader
## Overview
Automatic discovery and loading of `AGENTS.md` files across project hierarchies for AI coding agents. This skill scans the current workspace and its parent directories to locate agent instruction files, then surfaces their contents so the active agent session has full operational context.
## Prerequisites
- A project workspace containing one or more `AGENTS.md` files at any directory depth
- Read and Glob permissions to traverse the directory tree
- Grep access for searching file contents when multiple candidates exist
## Instructions
1. Scan the current working directory and all ancestor directories (up to the filesystem root or repository root) for files named `AGENTS.md` or `agents.md`.
2. Search subdirectories of the current workspace for additional `AGENTS.md` files that may apply to sub-projects or modules.
3. Determine load order: files closer to the repository root load first (global context), files in deeper directories load later (override or supplement).
4. Read each discovered `AGENTS.md` file and extract its instruction blocks, workflow definitions, and constraint declarations.
5. Merge instructions into a unified context, noting any conflicts between levels (e.g., a subdirectory agent overriding a root-level rule).
6. Present the loaded context as a structured summary: source file path, instruction count, and any detected conflicts.
7. Cache the discovery results for the current session to avoid redundant filesystem scans on subsequent activations.
## Output
- Ordered list of discovered `AGENTS.md` file paths with their directory depth
- Merged instruction set combining all discovered agent contexts
- Conflict report highlighting any contradictory directives between levels
- Session cache status indicating whether results are fresh or reused
## Error Handling
| Error | Cause | Solution |
|-------|-------|----------|
| No `AGENTS.md` found | Workspace has no agent instruction files | Confirm the correct working directory; create an `AGENTS.md` at the project root if needed |
| Permission denied on directory traversal | Restricted parent directories above the workspace | Limit scan depth to the repository root (detected via `.git/` presence) |
| Circular symlink detected | Symlinked directories create an infinite traversal loop | Skip symlinked directories during the scan; log a warning with the symlink path |
| Conflicting instructions across levels | A subdirectory `AGENTS.md` contradicts the root-level file | Flag the conflict in the output; apply the more specific (deeper) instruction by default |
| File encoding error | `AGENTS.md` uses a non-UTF-8 encoding | Attempt latin-1 fallback; report the file path and encoding issue |
## Examples
**Example 1: Monorepo with per-package agent instructions**
- Structure: Root `AGENTS.md` sets global conventions; `packages/api/AGENTS.md` adds API-specific tooling rules.
- Result: Both files loaded in order. The API-specific rules supplement the global context without conflict.
**Example 2: Nested workspace with conflicting commit policies**
- Structure: Root `AGENTS.md` says "always sign commits"; `services/legacy/AGENTS.md` says "skip commit signing."
- Result: Conflict detected and reported. The deeper (legacy) directive is applied with a warning noting the override.
**Example 3: First-time setup with no agent files**
- Structure: A freshly cloned repository with no `AGENTS.md` anywhere.
- Result: Scan completes with zero files found. Output includes a suggestion to create `AGENTS.md` at the repository root with a minimal template.
## Resources
- Claude Code AGENTS.md specification: https://docs.anthropic.com/en/docs/agents
- Monorepo workspace patterns for agent configuration: https://docs.anthropic.com/en/docs/claude-code
- File discovery best practices for hierarchical configuration loading
章节与文件索引
按说明文件中的顺序排列。
概述
先决条件
使用说明
输出
错误处理
文件/命令 -> AGENTS.md · agents.md · .git/ · packages/api/AGENTS.md · services/legacy/AGENTS.md
内容校验值 -> a45b85ffa4d5
当前原文的自动摘译,尚未人工审校。
概述
跨项目层次结构为 AI 编码代理自动发现和加载
AGENTS.md文件。此技能扫描当前工作区及其父目录以查找代理指令文件,然后显示其内容,以便活动代理会话具有完整的操作上下文。先决条件
一个项目工作区,包含任意目录深度的一个或多个
AGENTS.md文件 具有读取和 Glob 权限,用于遍历目录树 存在多个候选时,用于搜索文件内容的 Grep 访问权限使用说明
扫描当前工作目录和所有祖先目录(直到文件系统根目录或存储库根目录)以查找名为
AGENTS.md或agents.md的文件。在当前工作区的子目录中搜索可能适用于子项目或模块的其他AGENTS.md文件。确定加载顺序:靠近存储库根目录的文件首先加载(全局上下文),较深目录中的文件稍后加载(覆盖或补充)。输出
发现的
AGENTS.md文件路径的有序列表及其目录深度合并的指令集组合了所有发现的代理上下文冲突报告突出显示级别之间的任何矛盾指令会话缓存状态指示结果是新鲜的还是重复使用的错误处理
错误 · 原因 · 解决方案 未找到
AGENTS.md· 工作区没有代理指令文件 · 确认工作目录正确;如果需要,在项目根目录创建一个AGENTS.md目录遍历的权限被拒绝 · 限制工作区上方的父目录 · 将扫描深度限制到存储库根目录(通过.git/存在进行检测) 检测到循环符号链接 · 符号链接目录创建无限遍历循环 · 在扫描期间跳过符号链接目录;使用符号链接路径记录警告