src/skills/x-internal-load-agent-context/SKILL.md
Resolves an agent name or path and returns its persona, core knowledge, tools, and rules as a structured JSON envelope for injection into the calling skill's context.
npx skillsauth add edercnj/claude-environment x-internal-load-agent-contextInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Emit a single-line JSON envelope on success. On error, emit a JSON object with status: "error" and message. No greetings or explanations.
🔒 INTERNAL SKILL — Called only by orchestrating skills. Not user-invocable.
Resolves an agent file by name or path, reads it, and returns its persona, core knowledge directives, tools, and rules as a structured JSON envelope. This skill is the canonical implementation of the agent binding mechanism.
Callers must inject the returned context into their execution before proceeding with domain logic.
Only called by other skills via Skill(skill: "x-internal-load-agent-context", args: "--agent <name>").
| Parameter | Required | Default | Description |
|-----------|----------|---------|-------------|
| --agent | Yes | — | Agent name (e.g. devops-engineer) or relative path (e.g. .team-development/src/agents/devops-engineer.md) |
| --team | No | — | Team directory to search first (e.g. .team-development). Overrides default resolution order for that team's agents. |
Input: --agent value.
Action:
--agent value contains / or \, treat as a relative path from repo root. Verify the file exists; if not, halt with error.src/agents/<name>.md
b. .team-development/src/agents/<name>.md
c. If --team was provided: <team>/src/agents/<name>.md (checked before step b){"status": "error", "message": "Agent '<name>' not found. Searched: src/agents/, .team-development/src/agents/"}
Output: Resolved absolute or relative path to the agent file.
Input: Resolved agent file path.
Action:
name → agent_namedescription → agent_descriptiontools → tools (array)model → model## Persona section (or any H2 whose name contains "Persona"). If absent, use the description frontmatter value.Read <path> directives under ## Core Knowledge section. Return as array of strings.## Rules section (last H2 named "Rules"). Return as array of strings.Output: Structured parsed data.
On error: If file is unreadable, return {"status": "error", "message": "Cannot read agent file at <path>: <os-error>"}.
Input: Parsed data from Phase 2.
Action: Emit the following JSON envelope to stdout (single line, no trailing newline):
{
"status": "ok",
"agent_name": "<name>",
"agent_description": "<description>",
"model": "<model>",
"tools": ["Read", "Bash", "Grep"],
"persona": "<persona text>",
"core_knowledge": [
"Read src/knowledge/shared/governance-baselines/coding-standards-rule/knowledge.md",
"Read src/patterns/backend/software-architecture/hexagonal/patterns.md"
],
"rules": [
"REQUEST CHANGES if container runs as root",
"NO-GO if ANY item in Architecture (1-8) fails"
],
"full_body": "<complete agent markdown body>",
"source_path": "src/agents/devops-engineer.md"
}
Orchestrating skills should follow this pattern in their Phase 0:
## Phase 0.1 — Load Agent Context (when --agent provided or agent: frontmatter set)
**Input:** `--agent` value or `agent:` frontmatter field.
**Action:**
Skill(skill: "x-internal-load-agent-context", args: "--agent <agent_name>")
**Output:** `agent_context` envelope.
**Inject:** Adopt the `agent_context.persona` as the active persona for the remainder of this skill's execution. Follow `agent_context.rules` as additional constraints. Read all paths listed in `agent_context.core_knowledge` before proceeding.
**On error:** If `agent_context.status == "error"`, halt and surface `agent_context.message`.
| Field | Type | Description |
|-------|------|-------------|
| status | "ok" | "error" | Resolution status |
| agent_name | String | Agent name from frontmatter |
| agent_description | String | Agent description from frontmatter |
| model | String | Model declared by the agent |
| tools | Array | Tools the agent is allowed to use |
| persona | String | Persona text extracted from ## Persona section |
| core_knowledge | Array | Read directives from ## Core Knowledge |
| rules | Array | Absolute constraints from ## Rules |
| full_body | String | Complete agent Markdown body (sans frontmatter) |
| source_path | String | Relative path to the resolved agent file |
--agent is provided but the file is not found — always halt with a clear errorsrc/agents/ before .team-development/src/agents/ (unless --team overrides)--agent value is a path (contains / or \), skip name-based resolution entirely| Code | Condition |
|------|-----------|
| AGENT_NOT_FOUND | No file matched the name in any search location |
| AGENT_FILE_UNREADABLE | File exists but cannot be read (permissions, encoding) |
| AGENT_PARSE_FAILED | File is not valid Markdown with YAML frontmatter |
| MISSING_ARGUMENT | --agent flag absent from argv |
development
Documentation freshness gate: validates 6 dimensions (readme, api, adr, etc.) per PR.
testing
Conditional dep-policy gate: CVEs, licenses, versions, freshness; SARIF + report.
documentation
Incrementally updates the service or system architecture document; never regenerative.
development
Scans code and git history for leaked credentials, API keys, and tokens; SARIF output.