Repository navigation
Plugin Layout Slices
A slice is one feature of a plugin, in one folder. This page shows what a slice folder holds, how its texts work, and how to add a slice. It follows Plugin Layout.
The handoff slice shows the usual parts:
src/plugins/claudetto/slices/handoff/
slice.ts the manifest: the name, the ladder line, and each part
limits.ts the bounds of the slice
domain/ pure code: data and functions, no I/O
adapters/mod.ts mod handlers
prompts/ the texts for Claude and for the user
evals/handoff/ eval cases
lab/compaction.test.ts a hook lab test
Other slices add these parts when they need them.
| Part | Use | Output in plugins/<plugin>/
|
|---|---|---|
slice.ts |
Always. It exports slice, and slice.name equals the folder name |
Lines in plugin.json, hooks.json, and register.ts
|
domain/ |
Pure logic, with no adapter import | slices/<s>/domain/ |
adapters/mod.ts |
The functions that a mod handler runs |
hooks/register.ts and slices/<s>/adapters/mod.ts
|
adapters/cli.ts |
A CLI that exports main
|
bin/<bin>, a launcher, and slices/<s>/adapters/cli.ts
|
skills/<name>/SKILL.md |
A skill | skills/<name>/SKILL.md |
styles/<name>.md |
An output style | output-styles/<name>.md |
prompts/ |
Texts for Claude or the user | slices/<s>/prompts.ts |
lab/*.test.ts |
Hook lab tests |
tests/*.test.ts, run by claude plugin test
|
evals/<case>/ |
Eval cases | evals/<case>/ |
limits.ts |
The bounds of the slice | slices/<s>/limits.ts |
The skills field of slice.ts declares the skills the slice ships.
Each text of a slice that goes to Claude or to the user is a file in prompts/, not a string in the code.
Examples are a deny reason, a notice, and the prompt of a side model.
tools/generate/emit/prompts.ts writes the module prompts.ts from the folder.
The code imports each text from ../prompts.ts.
| Source | Export in prompts.ts
|
|---|---|
prompts/deny-reason.md |
DENY_REASON, a string |
A .md file with a parameter such as {{command}}
|
A function, such as DENY_REASON({ command }), that gives a string |
prompts/automode.json |
AUTOMODE, an object |
- A lowercase name in double curly braces is a parameter. The code gives its value as a string at run time.
- An uppercase name in double curly braces is a value that the generator fills from
limits.tsof the slice, or fromVALUESintools/generate/emit/fill.ts. A number gets the form20,000. - A line
{{include name}}gives the text ofsrc/fragments/name.md. - The code keeps the choice between texts, the short labels, and the log lines.
Hook lab tests in lab/ import the texts from ../prompts.ts, and just generate changes the import to the module in the copy of the slice.
The description of a plugin is description.md, with one sentence on each line, and just generate joins the lines into the manifest.
- Choose the plugin. A feature that costs tokens when unused, or that needs an outside tool, goes in an add-on (Add-Ons).
- Create
src/plugins/<plugin>/slices/<s>/slice.ts. Exportslicewithnameset to the folder name and aladderline. Add each part the slice needs, such asmod,cli,skills, oruserConfig. The contract is insrc/kernel/slice.ts. - Add the code.
Put the logic in
domain/and the entry points inadapters/. Export each mod handler fromadapters/mod.ts, and name it inrun. - Add the texts.
Put each skill in
skills/<name>/SKILL.md, and each message inprompts/<name>.md. - Add the bounds to
limits.tsof the slice, and shared bounds tosrc/kernel/budget.ts. Never put a bound in two files. - Add the tests.
Put repository tests in
tests/<folder>/<s>/and hook lab tests inlab/. Name each hook eval inevalsof its mod handler. Add acontrolsrecord for each hook. - For a new plugin, add
src/plugins/<plugin>/plugin.tsthat exportsplugin, adescription.md, and the name insrc/marketplace.ts. - Run
just generate, thenjust check. Commit the source and the generated files together.
The fixture of the generator tests is in tests/tools/generate/fixture/.
claudetto
- Start
- Slices
- Add-Ons
- Reference
- Rationale
- Evidence
- Development
Claude Code