Repository navigation
Proposal: rules as a portable plugin component #100
Replies: 5 comments 3 replies
|
The companion proposal on the hook events each client version supports is now posted as #101. |
|
+1, and some data from the other direction. i maintain kitbag, a cli that converts one rules/ dir into each client's format, so i've had to map these: client file-scoped rules frontmatter for scope what round-trips losslessly for me is three fields: globs, alwaysApply, description. "on demand by description" has no equivalent in claude code (it just loads), and folding into one file loses conditionality entirely. so i'd suggest the spec require those three fields and say explicitly what a client without file-scoped rules should do (fold, labelled with the globs, is what i do). |
|
@cargopete Thanks for the mapping. It comes from a converter that already runs, which is the evidence the proposal lacked. I agree with both suggestions, with one reading of the first. The spec defines For a client without file-scoped rules, the spec would say: load the rule always-on, and label it with its scope. Loading a rule more broadly keeps it in force, while dropping it would lose the rule without telling anyone. agent-shared now does this (cardene777/agent-shared#44). Take this rule: ---
globs: src/**/*.ts, test/**/*.ts
---
# TypeScript
Use `unknown` instead of `any` for values from outside the program.Codex's <!-- agent-shared rule typescript.md -->
> Applies when working on files that match `src/**/*.ts`, `test/**/*.ts`.
# TypeScript
Use `unknown` instead of `any` for values from outside the program.A rule with only Claude Code reads only ---
paths:
- "src/**/*.ts"
- "test/**/*.ts"
---
# TypeScript
Use `unknown` instead of `any` for values from outside the program.agent-shared reads The three clients name the field differently: Would kitbag read a plugin's I prepared this reply with an AI coding agent and reviewed it myself. |
|
@cargopete Good, then A plugin source in kitbag would help. In the proposal, a plugin keeps its rules in a With your two points, the proposal changes in three places:
I would take these three changes into the spec text once the maintainers have weighed in. I prepared this reply with an AI coding agent and reviewed it myself. |
|
@cargopete Thanks for building this, and for the credit in NOTICE. With cargopete/kitbag#78, kitbag reads a plugin's The two word the label differently. kitbag writes That gives the I prepared this reply with an AI coding agent and reviewed it myself. |
Uh oh!
There was an error while loading. Please reload this page.
A companion proposal covers the hook events each client version supports: a separate Discussion in this category, linked in a comment below.
Discussion-first proposal per CONTRIBUTING.md. Related threads: #47 proposes a plugin-level orientation file, which describes the plugin, while this proposal covers rules loaded in every session; #35 asks for path-scoped rules on the roadmap.
Summary
Many plugins need always-on instructions next to their skills: coding conventions, safety rules, or the steps a team follows.
The specification leaves rules outside the format "until their formats converge".
This proposal suggests that the content has already converged on plain Markdown, and that only the place each client loads it from differs.
It proposes a small
rules/component and two client requirements, and offers one placement pattern that was run on three clients.Problem
A plugin that ships skills and MCP servers portably still has no portable way to ship the instructions that go with them.
Each client reads always-on instructions from its own place:
~/.claude/CLAUDE.md, and every Markdown file in~/.claude/rules/~/.codex/AGENTS.md~/.copilot/copilot-instructions.mdAGENTS.mdat the repository root, read by Codex and others, and by Claude Code through@AGENTS.mdinCLAUDE.mdSo a plugin author either keeps one copy per client or asks users to paste the text by hand.
Pasted text cannot be told apart from the user's own lines, so disabling or uninstalling the plugin leaves its rules behind, still loaded.
Who hits it
Why it belongs in the portable specification
The content is the same in every client: Markdown read as instructions for the whole session.
What a client cannot decide alone is where a plugin keeps its rules and what enabling and removing them guarantees, since a plugin is written once for every client.
Placement inside each client can stay client policy.
Proposed shape
rules/directory at the plugin root holding*.mdfiles, one rule per file, the file name being the rule name.A placement pattern for clients that read one instructions file
A client that reads instructions from one file can still meet the removal requirement exactly:
A client that reads a folder of rule files, like Claude Code's
~/.claude/rules/, can place one link per rule and remove the links it recorded.Evidence
agent-shared (definition) places one folder of skills, rules, and hooks into several clients and takes them out again.
Its rules placement is the pattern above, run on these clients and versions:
~/.claude/rules/~/.codex/AGENTS.md~/.copilot/copilot-instructions.mdAGENTS.mdIts tests check that the lines outside a block keep their bytes, that removing a source takes out only its block, also after the source folder is deleted, and that a file left holding nothing is removed.
Who would adopt it
rules/directory as a source.AGENTS.md-style files could load an enabled plugin'srules/*.mdwith a small change; we cannot speak for client vendors and would like to hear from them.Open questions
applyToor Cursor's glob rules, which this proposal leaves out of a first version.This proposal was prepared with an AI coding agent and reviewed by me.
All reactions