Skills
How zelk loads and runs skills. The skill package implements the format.
Lifecycle
Section titled “Lifecycle”- Sources. The host passes
zelk.WithSkills(source...), and may passzelk.WithSkillDiscovery(find)to find more as sessions reach directories: when Read, Edit, Write, Glob or Grep reaches a workspace directory for the first time,findreturns its sources (the CLI’s are the skill directories between the working directory and it,skill.Below). Found sources stay with the agent, afterWithSkills’ (a name clash keeps the earlier skill), and the call records the session’s new index (SkillsIndexed), so the model hears of the added skills before its next call.Newloads them: invalid skills and collision losers become warnings, recorded afterSessionStartedin every new session. Every execution’s start loads them again, as Claude Code picks up skills added or edited mid-session, so a new session’s index, theSkilltool and invocation by name see the files as they are then; warnings of a reload are logged. A source may be a directory of command files (skill.Commands), Claude Code’s older single-file format: each one loads as a skill of one file, named by its path (frontend:component). - Index. Each session records the index (
event.Config.Skills: name, description, source, trust, revision) and the model sees it in the dynamic context, never in the cached system prompt. When a reload finds an index other than the session’s newest,SkillsIndexedrecords it. As with memory, the model is told before its next call which skills were added, had their description changed or were removed (a changed revision alone needs no note:Skillloads the current files), and the index reaches the request context at the next compaction, so the cached prefix holds until then. A session without theSkilltool, such as a subagent narrowed to other tools, records none. - Load. The model calls
Skill{name}, or the user invokes/name args(Session.InvokeSkill,Session.Prompt). The bundle is stored among the session’s outputs andSkillLoadedrecords its manifest. It includes the skill’s regular files and descends into hidden directories underscripts/. Hidden entries elsewhere, such as.envand.git, can contain local secrets and are excluded. Links inside the bundle are never followed. Before framing, the body’s placeholders take the user’s arguments ($ARGUMENTS,$N, declared$names) and${ZELK_SESSION_ID},${ZELK_SKILL_DIR},${ZELK_PROJECT_DIR}and${ZELK_EFFORT}(also asCLAUDE_…), as Claude Code fills them (skill.Expand); arguments no placeholder took follow the instructions. The invocation records the expanded text, so replay never expands again. The model receives the instructions framed by trust, the list ofskill://files, where scripts run, and the tools the skill allows. - Active. A skill is active from its load until its run ends or another skill loads. A skill the user invokes during a run becomes active with the next run its message starts.
- Replay. Replay and resume use the recorded index, manifests and rendered text. No skill file is read again during replay.
Files named with @
Section titled “Files named with @”An invocation attaches the files and MCP resources it names with @, as a message does (Agent.Attach; InvokeSkill.Files): those in the user’s arguments always, and those in the skill’s own text when the skill is the user’s own (host trust). A project’s skill or command can’t attach files: naming one isn’t the user reading it, so the model reads it with Read, under the session’s rules.
Shell lines
Section titled “Shell lines”A skill’s !`command` lines run as the user invokes it, and each line’s output takes its place before the message is sent, as in Claude Code: a ! that starts a line or follows a blank, then a command up to the next backtick on that line; or a fenced block opened by a line that is exactly ```! and closed by ```, whose lines are one command. This happens in Session.InvokeSkill, before the invocation is recorded, as reading the files @ names does; the invocation records the commands (InvokeSkill.Commands) and the text holds their output.
- Hooked as Bash. The session’s PreToolUse hooks for Bash run on each command first (
loop.SkillShellHooks), and combine as a call’s do: a deny refuses it, even in bypass mode, an ask needs a person, an allow stands in for an allow rule, and a rewritten command is the one decided and run. A hook that fails or times out denies. Claude Code doesn’t say its hooks see these commands; zelk runs them because a hook is often the user’s policy, and a project skill’s commands shouldn’t get past it. - Decided as Bash. Each command is decided as a Bash call of the session would be in the start it goes with (
loop.DecideSkillShell): under the policy that start gives the session, a launch’s withzelk.WithLaunchPolicy()(permissions): deny rules, plan mode, protected paths, the read-only allowlist and allow rules, with a host-trust skill’sallowed-toolsas allow rules, as while it is active. No turn is under way, so no reviewer runs: what auto mode would review is asked of a person. Every command is decided before any runs, so a refused one refuses the invocation with nothing run. - Asked of a person. A host passes
zelk.WithShellApprovalto ask about a command the permissions ask about: the TUI’s approval dialog, ACP’ssession/request_permission. Approving runs it once; no rule is kept. Without an approver, as in print mode, the invocation is refused, naming a rule that would allow the command. Claude Code refuses every command its permissions don’t allow; zelk asks, since a person at the keyboard can judge one command. - Run as Bash. A command that names one of the skill’s scripts runs only if the script is as the skill was loaded (
shell.CheckScripts, the check of the Bash tool and the PowerShell tool alike). The commands run in Bash where the session has it and otherwise in PowerShell (on Windows without Git for Windows, or under MXC); then the hooks that run first are those forPowerShell, and each command is decided as a PowerShell call. The bundle records digests for hidden scripts and scripts inside hidden directories underscripts/as well. Commands run in the agent’s environment under its launcher, from the session’s working directory, with that shell and the Bash tool’s timeout (zelk.SkillShellTimeout, two minutes). Output is bounded as a Bash call’s is. A command that exits non-zero, times out or is killed refuses the invocation (ErrSkillShell) with the end of its output: a message built on a failed command would mislead the model. - The skill’s directory, only in the workspace.
${CLAUDE_SKILL_DIR}is a directory a command can use only for a skill in the workspace. A skill from elsewhere, a personal one among them, has none the environment can see (its files areskill://paths, and its scripts run only once published), so a line that names it refuses the invocation before anything runs. Claude Code gives such a skill its path on the host; zelk’s environment may be a sandbox or another machine, and scripts are checked against the recorded bundle. - Not for the model. When the model loads a skill with
Skill, its lines stay as written and it is told to run what it needs with Bash, where each command is decided as any call is. - Commands don’t take the session’s workspace lock: one sent while a run is under way runs beside it, as a TUI shell-mode command does.
Safety
Section titled “Safety”- Skills can’t change the permission mode or bypass the decision procedure (permissions.md).
allowed-toolspre-approves, as in Claude Code: while a host-trust skill is active, each entry (Read,Bash(git commit:*)) is an allow rule beside the session’s, so deny rules, plan mode, protected paths and human-only rules still come first, and auto mode still drops rules that would run any code. Tools it doesn’t list keep their usual permission; nothing is narrowed, so a Claude Code skill works unchanged. A project-trust skill’sallowed-toolsgrant nothing: a repository’s files can’t approve their own actions, and no skill’s do in a session whose policy says skills grant nothing (zelk.WithoutSkillGrants, which a host sets under a managed policy’srules_only). The grant ends when the skill does.- A script runs only from a skill in the workspace, and Bash refuses a command naming a loaded skill’s script whose content changed or vanished since the load.
Warnings
Section titled “Warnings”| Code | When |
|---|---|
skill_invalid |
a skill failed validation and was skipped |
skill_description_unclear |
a model-invocable skill’s description has fewer than 3 words, too few to say what it does and when to use it |
skill_descriptions_overlap |
two model-invocable skills’ descriptions share 80% or more of their words, so the model can’t tell which to use |
skill_file_skipped |
a bundle holds a link or device, which is never followed or bundled |
skill_shadowed |
two skills share a name; the warning names the one ignored |
skill_source_unreadable |
a source’s directory can’t be listed |
skill_index_full |
the index bound (1% of the context window, skill.IndexBytes) left skills unlisted (they still load by name, and the context names them, Config.UnlistedSkills) |
skill_scripts_unavailable |
a loaded skill has scripts but isn’t in the workspace |