Tool, Command, and Config
$.tool lists, checks, calls, and registers tools.
$.command does the same for slash commands.
$.config lists and sets the rows of the /config menu.
A hook on tool.call or command.run serves a tool or command that a mod registers.
A deny from a tool.call, tool.check, or config.set hook stops the action. A registered tool has the name mcp__<plugin>__<name>.
Official pages: Use the Mods API, Mods Reference. Source: the Mod API type file of the 2.1.312 program (schemas/claude-code.d.ts).
"Run time" appears in a "Where it can be used" cell. It means in a hook, in a closure that a hook drew, or in a timer callback. It does not mean inside register.
Example
This mod adds a /standup command.
on("session.start", async ($, e, next) => {
await $.command.register({
name: "standup",
description: "Summarize what changed today",
argumentHint: "[days]",
});
return next(e);
});
on("command.run", { command: "standup" }, async ($, e) => ({
text: `Summary for ${e.args || "1"} day(s)`,
}));
Members
| Item | Status | What it does | How it works | Where it can be used |
|---|---|---|---|---|
$. | Documented: An official docs page names this item. | Returns the tools the model can call now, built-in and MCP, in the order the model sees them. | () => Promise<Tool. | Run time. |
$. | Documented: An official docs page names this item. | Calls a tool. It is the event tool., the same call the engine makes for the model, under a tool_ of its own. | Runs a tool through the hooks, the permission check, and the tool. Rejects for an unknown name or an aborted call. Example: await $.. | Run time. |
$. | Documented: An official docs page names this item. | Asks for the permission decision for a tool call now. It is the event tool.. Resolves { decision, reason?, .... | (input:. Nothing runs and no dialog opens. | Run time. |
$. | Documented: An official docs page names this item. | Declares a tool the model can call from the next prompt on: the name, description, and input schema of mcp__. | (tool:. Serve it with a tool. hook. A second registration of a name replaces the first. | After the session binds at session. (rejects before). |
$. | Documented: An official docs page names this item. | Returns the slash commands the person can run now, built-in, plugin, and MCP, in typeahead order. | () => Promise<Command. | Run time. |
$. | Documented: An official docs page names this item. | Runs a slash command as if the person typed /. It is the event command.. It queues and runs once the session is idle. | (input:. Rejects an unknown name. | Run time. |
$. | Documented: An official docs page names this item. | Declares the slash command / for this session, listed in the typeahead from the next keystroke on. | (command:. Serve it with a command. hook. The engine refuses a built-in's name. | Run time. |
$. | Documented: An official docs page names this item. | Returns the rows the / menu would draw now, in its order, each with its value, kind, owner, and lock. | () => Promise<Config. Lists the rows after every config. hook. The list omits a hidden row. | Run time. |
$. | Documented: An official docs page names this item. | Changes one row as if the person did in the menu. It is the event config. with origin { kind:. | (input:. Resolves { value } or { deny }. Rejects a key that no row has. | Run time. |
Engine Events
| Item | Status | What it does | How it works | Where it can be used |
|---|---|---|---|---|
tool. | Documented: An official docs page names this item. | Fires when the engine is about to run a tool. Each next(e) runs the hooks beneath, then core (the permission prompt, the tool). | Input Tool. Result { result, context? } or { deny }. { deny: refuses the call. The engine skips a guard that fails, and the tool runs. | on('tool.. Also $.. |
tool. | Documented: An official docs page names this item. | Fires when the engine decides whether a tool call may run, after the tool. and Pre hooks and before the mode settles an ask. | Input Tool, which carries is when the call is read-only (new in 2.1.304) and, since 2.1.307, approver, who can answer an ask. Result { decision, reason?, .... Since 2.1.307 an ask that a hook makes goes to a person, and the engine marks it with plugin: only the permission dialog, a host's callback, or a Permission hook can approve it, and where nobody can be asked (dont mode, avoid-prompts, headless) it is refused with the mod's reason. The 2.1.304 decider: field is still read but is no longer in the type file. next(e) gives the engine's verdict. A guard that fails is skipped, so add a .. | on('tool.. Also $.. |
tool. | Documented: An official docs page names this item. | Fires when the engine first renders the tool's schema in a session. next(e) resolves to { description, is. | Input Tool. The engine caches the answer until $.. | on('tool.. In tests: $. on the test engine (not on a hook's $). |
command. | Documented: An official docs page names this item. | Fires when a slash command is about to run. next(e) resolves to { text }, its output. | Input Command. Rewrite args with next, or return { text } to answer in its place. | on('command.. Also $.. |
command. | Documented: An official docs page names this item. | Fires once for each command, when the engine lists it for the typeahead and /. next(e) resolves to { description, argument. | Input Command. The engine caches it for the session until $.. | on('command.. In tests: $. on the test engine (not on a hook's $). |
config. | Documented: An official docs page names this item. | Fires when a / row is about to change, from the menu or a plugin's $.. next(e) resolves to { value } once written. | Input Config. Result { value } or { deny }. { deny: leaves the row as it is. The engine refuses a value of the wrong kind. | on('config.. Also $.. |
config. | Documented: An official docs page names this item. | Fires once for each / row, when the menu lists it and for $.. next(e) resolves to { label, description, is. | Input Config. The engine caches it until $.. | on('config.. In tests: $. on the test engine (not on a hook's $). |
Events Raised by These Calls
For each call, a hook above the caller returns next(e), { deny: reason }, or { value }.
| Item | Status | The argument | Input and value |
|---|---|---|---|
tool. | Documented: An official docs page names this item. | $. | Input No. Value Tool. |
tool. | Documented: An official docs page names this item. | $. | Input Registered. Value { tool:. |
command. | Documented: An official docs page names this item. | $. | Input No. Value Command. |
command. | Documented: An official docs page names this item. | $. | Input Command. Value { command:. |
config. | Documented: An official docs page names this item. | $. | Input No. Value Config. |
Related Pages
- Mod API Overview
- Turn and Prompt
- Tool, Command, and Config Types (tool call, check, command, and config types)