Serves skills from .agents/skills (project and home) and Moxen's bundled skills to Claude Code, without copying them into .claude/skills.

moxen drives provider CLIs directly from your terminal: a full interactive TUI for working with threads, plus a scriptable CLI for handovers, thread inspection, messaging, and automation. Threads, projects, and orchestration live in a local store (~/.moxen), and turns run against claude or opencode serve through their own logins.
Bun (it manages packages and runs everything) and at least one provider CLI: claude (claude auth login) or opencode v2 or newer (opencode auth login, including openai for ChatGPT and xai for SuperGrok, or provider API keys).
git clone https://github.com/arrrnmp/moxen.git
cd moxen
bun install
Build the bundle once, and again after pulling changes (it takes a second or two):
bun run build
Then point a moxen command at dist/, from any working directory, with nothing to put on PATH.
macOS/Linux (bash/zsh) — add to your shell profile (~/.bashrc, ~/.zshrc, ...):
moxen() { bun "/absolute/path/to/moxen/dist/cli/index.js" "$@"; }
Windows (PowerShell) — add to your $PROFILE:
function moxen { bun "C:\absolute\path\to\moxen\dist\cli\index.js" @args }
Reload the shell, then verify:
moxen --json doctor
Every example below assumes moxen resolves that way. This package is not published (private: true), so install it by cloning.
moxen tui
Opens the interactive client: sidebar with your threads, the live transcript with per-turn diffs, and a composer with model/effort pickers, image attachments, and an external-editor shortcut. Clicking a user prompt opens message actions (copy, revert); clicking a diff-turn header jumps the transcript to that turn; the command palette covers copy/thread/jump actions.
| Keys | Action |
|---|---|
enter | Send (composer) / confirm (close menu) |
shift+enter, ctrl+j | Newline in the composer |
esc | Unfocus composer / close diff / cancel menus |
ctrl+c | Clear prompt → close menu → quit (empty prompt jumps straight to the menu) |
ctrl+t | Toggle tasks panel |
ctrl+p | Command palette |
ctrl+o, alt+e | Edit the draft in $VISUAL / $EDITOR |
ctrl+v, cmd+v | Paste an image from the clipboard |
i | Focus the composer |
s, [, ] | Sidebar mode / cycle project |
arrows, pgup/pgdn | Scroll the focused pane |
The UI needs at least a 180×47 terminal (btop-style): below that it shows a resize notice instead of a broken layout, and resumes live when you grow it back. Resizes are followed over SSH too.
The same binary scripts everything the TUI does, with stable --json envelopes for automation:
moxen handover --prompt "Continue the implementation from this handover."
moxen threads list --status active --cwd .
moxen threads send --thread <thread-id> --prompt "Run the morning check."
Full reference: docs/cli.md. How it runs under the hood: docs/overview.md, docs/threads.md, docs/providers.md.
There are no bearer tokens anywhere in this stack: provider CLIs own their own logins, and this CLI never reads their secrets — it only observes credential presence for status display. Threads live as local JSONL under ~/.moxen (override with MOXEN_STORE_ROOT).
AGPL-3.0-only. See LICENSE. The tree-sitter grammars under src/core/syntax/ are attributed in THIRD_PARTY_LICENSES.md.
hooks/register.ts 215 lines1import type { Register } from 'claude-code'
2
3/**
4 * Skills that live outside `.claude/skills`, served to Claude Code.
5 *
6 * `.agents/skills` is the folder Codex, OpenCode and Grok read; Claude Code
7 * reads only `.claude/skills`. Instead of copying or linking every skill into
8 * `.claude/skills` (and keeping the copies current), this mod finds them where
9 * they are and offers them two ways:
10 *
11 * - to Claude, as one tool whose description lists the skills and whose call
12 * returns a skill's instructions (what the built-in Skill tool does);
13 * - to the person, as a `/<name>` command that runs the skill.
14 *
15 * Looked up, first match wins by name: `<project>/.agents/skills`,
16 * `~/.agents/skills`, then the folder named by `MOXEN_SKILLS_DIR` (Moxen's own
17 * bundled skills, which it sets for the sessions it starts). A skill that
18 * `.claude/skills` already provides is left to Claude Code.
19 *
20 * Moxen's skills are the bundled ones and the copies it marked
21 * (`.moxen-skill.json`). For the sessions it starts, Moxen may also set
22 * `MOXEN_SKILLS_HIDE` (comma-separated names of its skills to leave out) and
23 * `MOXEN_OWN_SKILLS=0` (offer only Moxen's skills, none of the user's).
24 */
25
26type Skill = {
27 name: string
28 description: string
29 argumentHint: string | null
30 dir: string
31 body: string
32 /** `disable-model-invocation: true`: only the person runs it. */
33 userOnly: boolean
34 /** `user-invocable: false`: only Claude runs it. */
35 modelOnly: boolean
36}
37
38const TOOL = 'skill'
39const MARKER_FILE = '.moxen-skill.json'
40const TOOL_FULL_NAME = 'mcp__agent-skills__skill'
41/** Keeps the tool description, which rides in every request, to a size worth sending. */
42const LISTING_BUDGET = 8_000
43const DESCRIPTION_CAP = 250
44
45/** Splits `---` frontmatter from the body and reads its flat `key: value` lines (and `>`/`|` blocks). */
46export function parseSkill(text: string): { meta: Record<string, string>; body: string } {
47 const lines = text.replace(/\r\n/g, '\n').split('\n')
48 if (lines[0]?.trim() !== '---') return { meta: {}, body: text.trim() }
49 const end = lines.indexOf('---', 1)
50 if (end === -1) return { meta: {}, body: text.trim() }
51 const meta: Record<string, string> = {}
52 for (let index = 1; index < end; index += 1) {
53 const match = /^([A-Za-z][\w-]*):\s*(.*)$/.exec(lines[index] ?? '')
54 if (!match) continue
55 const key = match[1]!
56 let value = match[2]!.trim()
57 if (/^[>|][+-]?$/.test(value)) {
58 const parts: string[] = []
59 while (index + 1 < end && /^\s+\S/.test(lines[index + 1] ?? '')) {
60 index += 1
61 parts.push((lines[index] ?? '').trim())
62 }
63 value = parts.join(' ')
64 }
65 if ((value.startsWith('"') && value.endsWith('"')) || (value.startsWith("'") && value.endsWith("'"))) value = value.slice(1, -1)
66 meta[key] = value
67 }
68 return { meta, body: lines.slice(end + 1).join('\n').trim() }
69}
70
71/** The text a skill run hands over: `$ARGUMENTS` filled in, or the arguments appended when the skill has no slot. */
72export function expand(skill: Skill, args: string): string {
73 const given = args.trim()
74 let text = skill.body.replace(/\$ARGUMENTS\b/g, given)
75 if (given !== '' && !skill.body.includes('$ARGUMENTS')) text += `\n\nARGUMENTS: ${given}`
76 return `Base directory for this skill: ${skill.dir}\n\n${text}`
77}
78
79export function listing(skills: readonly Skill[]): string {
80 const lines: string[] = []
81 let used = 0
82 for (const skill of skills) {
83 if (skill.userOnly) continue
84 const description = skill.description.length > DESCRIPTION_CAP ? `${skill.description.slice(0, DESCRIPTION_CAP - 1)}…` : skill.description
85 const line = `- ${skill.name}: ${description}`
86 if (used + line.length > LISTING_BUDGET) {
87 lines.push(`- …and ${skills.filter((entry) => !entry.userOnly).length - lines.length} more (call the tool with a name to load one)`)
88 break
89 }
90 lines.push(line)
91 used += line.length + 1
92 }
93 return lines.join('\n')
94}
95
96export const register: Register = (on) => {
97 let skills: Skill[] = []
98
99 on('session.start', async ($, e, next) => {
100 const home = (await $.env.get('HOME')) ?? (await $.env.get('USERPROFILE')) ?? ''
101 const bundled = (await $.env.get('MOXEN_SKILLS_DIR')) ?? ''
102 const hidden = new Set(((await $.env.get('MOXEN_SKILLS_HIDE')) ?? '').split(',').map((name) => name.trim()).filter((name) => name !== ''))
103 const ownSkills = (await $.env.get('MOXEN_OWN_SKILLS')) !== '0'
104 const roots = [`${e.cwd}/.agents/skills`, home === '' ? '' : `${home}/.agents/skills`, bundled].filter((root) => root !== '')
105 const claudeRoots = [`${e.cwd}/.claude/skills`, home === '' ? '' : `${home}/.claude/skills`].filter((root) => root !== '')
106
107 const found = new Map<string, Skill>()
108 for (const root of roots) {
109 let entries: Awaited<ReturnType<typeof $.fs.list>> = []
110 try {
111 entries = await $.fs.list(root)
112 } catch {
113 continue
114 }
115 for (const entry of entries) {
116 // A symlink reads as `other` (users link skills in); anything that is not a plain file may hold one.
117 if (entry.kind === 'file' || found.has(entry.name)) continue
118 const dir = `${root}/${entry.name}`
119 const file = `${dir}/SKILL.md`
120 if (!(await $.fs.exists(file))) continue
121 const moxens = root === bundled || (await $.fs.exists(`${dir}/${MARKER_FILE}`))
122 if (!moxens && !ownSkills) continue
123 if (moxens && hidden.has(entry.name)) continue
124 let provided = false
125 for (const claudeRoot of claudeRoots) provided ||= await $.fs.exists(`${claudeRoot}/${entry.name}/SKILL.md`)
126 if (provided) continue
127 try {
128 const { meta, body } = parseSkill(await $.fs.read(file))
129 const name = meta.name && /^[\w-]{1,64}$/.test(meta.name) ? meta.name : entry.name
130 if (found.has(name) || (moxens && hidden.has(name))) continue
131 found.set(name, {
132 name,
133 description: meta.description ?? `The ${name} skill`,
134 argumentHint: meta['argument-hint'] ?? null,
135 dir,
136 body,
137 userOnly: meta['disable-model-invocation'] === 'true',
138 modelOnly: meta['user-invocable'] === 'false',
139 })
140 } catch {
141 // An unreadable skill is skipped, not fatal.
142 }
143 }
144 }
145 skills = [...found.values()].sort((left, right) => left.name.localeCompare(right.name))
146
147 if (skills.some((skill) => !skill.userOnly)) {
148 await $.tool.register({
149 name: TOOL,
150 description:
151 'Load a skill from .agents/skills: instructions for a kind of task. When a task matches one below, call this first with its name, ' +
152 'then follow what it returns. Skills listed here are not in the built-in Skill tool.\n\nAvailable skills:\n' +
153 listing(skills),
154 inputSchema: {
155 type: 'object',
156 properties: {
157 skill: { type: 'string', description: 'The skill name, as listed.' },
158 args: { type: 'string', description: 'Arguments for the skill, when it takes any.' },
159 },
160 required: ['skill'],
161 },
162 })
163 }
164 // Registered last: a name a built-in command holds throws, and that must not cost the rest.
165 for (const skill of skills) {
166 if (skill.modelOnly) continue
167 try {
168 await $.command.register({
169 name: skill.name,
170 description: skill.description.length > 120 ? `${skill.description.slice(0, 119)}…` : skill.description,
171 ...(skill.argumentHint === null ? {} : { argumentHint: skill.argumentHint }),
172 })
173 } catch {
174 // Taken by a built-in or another mod: that one wins.
175 }
176 }
177 return next(e)
178 })
179
180 on('tool.call', { tool: TOOL_FULL_NAME }, async ($, e) => {
181 const input = e as unknown as { skill?: unknown; args?: unknown }
182 const wanted = typeof input.skill === 'string' ? input.skill.trim().replace(/^\//, '') : ''
183 const skill = skills.find((entry) => entry.name === wanted)
184 if (!skill) {
185 const names = skills.filter((entry) => !entry.userOnly).map((entry) => entry.name).join(', ')
186 return { result: `No skill named "${wanted}". Available: ${names}` }
187 }
188 if (skill.userOnly) return { result: `The ${skill.name} skill can only be run by the user, with /${skill.name}.` }
189 return { result: expand(skill, typeof input.args === 'string' ? input.args : '') }
190 }).catch(async (_$, e, next) => next(e))
191
192 on('command.run', async ($, e, next) => {
193 const skill = skills.find((entry) => entry.name === e.command && !entry.modelOnly)
194 if (!skill) return next(e)
195 // The skill is the person's request: it starts a turn, as the built-in /skill commands do.
196 await $.prompt.submit({ text: expand(skill, e.args), asUser: true })
197 return {}
198 }).catch(async (_$, e, next) => next(e))
199
200 on('prompt.compose', async ($, e, next) => {
201 const result = await next(e)
202 if (!skills.some((skill) => !skill.userOnly)) return result
203 return {
204 sections: [
205 ...result.sections,
206 {
207 id: 'agent-skills:guide',
208 scope: 'session' as const,
209 text: `Skills in .agents/skills are loaded with the ${TOOL_FULL_NAME} tool, not the Skill tool. When the user's request matches one, load it first and follow it.`,
210 },
211 ],
212 }
213 })
214}
215