Unified Agent Skills
Overview
unified_agent/skills.py is the shared Agent Skills adapter for UnifiedAgent: it takes one canonical skills source directory and makes the same SKILL.md-based skills discoverable by both supported hosts. Claude Code discovers project skills under <workspace>/.claude/skills/, while Codex discovers the cross-agent location <workspace>/.agents/skills/; install_skills() validates each source skill and installs it into both locations.
The skill format is represented by the Skill dataclass in unified_agent/skills.py, with name, description, source path, markdown body, and parsed YAML frontmatter. load_skill(skill_dir) reads <skill-dir>/SKILL.md, requires YAML frontmatter delimited by ---, and validates the open Agent Skills baseline used by both hosts: the name must be lowercase/digit words joined by single hyphens, no longer than 64 characters, and must match the containing directory name; description is required and capped at 1024 characters. Validation failures are raised as SkillError from unified_agent/types.py.
Discovery is directory-based. discover_skills(source_dir) requires source_dir to exist, scans its immediate children in sorted order, and loads only child directories containing SKILL.md; nested skills are not recursively discovered. make_skill() is a small helper used by examples/tests to write a minimal valid SKILL.md.
Installation is handled by install_skills(workspace, source_dir, mode="symlink", force=False). It calls discover_skills(), errors if no skills are found, then installs every skill under both workspace / .claude/skills and workspace / .agents/skills. In the default symlink mode, _install_one() creates a directory symlink named after the skill and leaves an already-correct managed symlink unchanged; stale symlinks are replaced. Existing real directories or files are refused unless force=True. In copy mode, existing target directories are treated as managed and replaced on reinstall, making copy-mode installs idempotent for environments where symlinks are not desired.
UnifiedAgent wires skills in during preparation, not at construction. In unified_agent/agent.py, UnifiedAgent.__init__() stores skills_dir as a resolved path and keeps skills_install_mode; _prepare() creates the workspace and, when skills_dir is set, calls install_skills(self.workspace, self.skills_dir, mode=self.skills_install_mode) before launching tools or streaming to the backend. Because _prepare() is guarded by _prepared, skill installation normally runs once per UnifiedAgent instance before its first stream()/run().
lint_skill() is a portability warning layer, not part of installation. It scans the skill body for Claude-only constructs that Codex and other agentskills hosts ignore or cannot reproduce: $ARGUMENTS, dynamic shell injection markers !` , and ${CLAUDE_*} variables. Callers that publish cross-agent skills should run this lint separately; install_skills() validates spec compatibility but does not reject these portability warnings.
skills-lock.json is the repository-level lock for externally sourced skills. It has version: 1 and a skills mapping keyed by skill name. Each entry records the upstream source (mattpocock/skills), sourceType (github), the upstream skillPath to that skill's SKILL.md, and a computedHash for the locked content. unified_agent/skills.py does not read this lock file directly; it documents the selected skill set and integrity hashes used outside the runtime installer. Runtime selection for an agent is still controlled by the skills_dir passed to UnifiedAgent, which must contain directories matching the SKILL.md names that discover_skills() can load.
Coupling
- If a skill directory under the configured
skills_diris renamed, update thenamefield in that skill's SKILL.md at the same time;load_skill()in unified_agent/skills.py rejects mismatches between frontmatter name and directory name. - If host discovery paths change, update
CLAUDE_SKILLS_DIRandCODEX_SKILLS_DIRin unified_agent/skills.py together withUnifiedAgentexpectations in unified_agent/agent.py;_prepare()assumesinstall_skills()is the single place that fans one source directory out to both backends. - If skills-lock.json is regenerated or a locked skill is upgraded, keep the lock entry's key,
skillPath, and the skill's frontmatternamealigned with the actual source directory; the runtime installer ignores the lock and will only install what exists under the passedskills_dir. - If adding stricter validation to
load_skill(), check both discovery and install flows:discover_skills()stops onSkillError, andUnifiedAgent._prepare()will fail before any backend run whenskills_dircontains an invalid skill.
Risks
- unified_agent/skills.py installs into both
.claude/skillsand.agents/skillsbefore a run. If either target already contains a user-managed real directory with the same skill name andforceis not enabled,install_skills()raisesSkillError, soUnifiedAgent._prepare()in unified_agent/agent.py fails before the agent starts. - skills-lock.json is not consumed by unified_agent/skills.py. If the lock file is updated without updating the actual
skills_dircontents used at runtime, the documented locked versions and the skills installed into workspaces can diverge silently.