Skip to main content

Module agentfiles

Module agentfiles 

Source
Expand description

The three things semlith setup writes for an agent beyond its MCP registration: the Agent Skill, the steering hook, and the rule block.

Registering the server tells a client that semlith exists. None of these does anything a registration does — they are what makes an agent use it. The skill teaches; the hook catches the moment it forgets; the rule block is for clients that read prose and have no skill directory.

Every path here comes from an annotated fence in docs/clients.md, except the cross-client skill directory below, which belongs to no client. Nothing in this file is a path retyped into Rust.

§What this writes, and what it leaves alone

Every file semlith does not own is backed up beside itself before its first write, and every write is reversible:

  • The skill is a link into a canonical copy under the store home. Removing the canonical directory removes all of them.
  • The hook is one entry in a client’s PreToolUse array. It is found again by the command it runs, so setup --no-hooks takes out exactly the entry semlith put there and leaves every other hook in place.
  • The rule block sits between two markers. A second run replaces what is between them; nothing outside them is read or written.

Enums§

State
Whether a thing semlith writes is there, absent, or there but out of date.

Constants§

SKILL_NAME
The skill’s name, which is its directory’s name everywhere it is linked.

Functions§

canonical_skill_dir
The canonical copy every link points at.
explorer_installed
Whether the semlith-explorer agent is written and current.
hook_clients
Every client that documents a PreToolUse hook, with the file it goes in.
hook_state
Where the hook is, per client, for one mode.
install_explorer
Write the semlith-explorer agent for Claude Code, when Claude Code is on this machine (its ~/.claude exists). None when there was nothing to do.
install_hooks
Merge the hook into every client that documents one.
install_rules
Write the rule block into every rules file semlith knows a path for.
install_skill
Write the canonical skill and link it into every documented directory.
installed_mode
The mode a settings file’s semlith hook runs in, if it has one.
remove_explorer
Take the agent out again. Only a file that is semlith’s: one naming itself semlith-explorer in its frontmatter.
remove_hooks
Take semlith’s hook back out, leaving every other hook in the file.
remove_skill
Remove the canonical skill and every link into it.
rules_state
Every client whose rules file semlith knows, and every one it does not.
set_always_load
Set "alwaysLoad": true on Claude Code’s user-scope semlith entry (4.1).
skill_dirs
Every user-level skill directory to link into: the cross-client one, then each one a client documents.
skill_state
Where the skill is, per directory.