Repository navigation
feat(rules): select rules per target with the include rules option - #4017
Merged
Merged
Conversation
Add an `include` option to a target's `rules` feature options in the object form of `targets`. When set, the target receives only the named rules, local and fetched (.curated) alike, so fetched rules can be routed per tool without editing frontmatter that install rewrites. Names match like sources[].rules (file name without .md; nested rules by path), an unknown name fails generate, and the targets frontmatter still applies on top. Works in project and global mode. Closes #4016 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01JdNNKCxxrKAMDANMGDEGP4
Read the rules `include` option from the configuration file even when --targets replaces the object form of targets, so a narrowed run never writes the rules a target deliberately excludes. Apply `include` in the import fold-duplication check too (falling back to every rule on an invalid selection), and document that targets sharing an output file share one selection. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01JdNNKCxxrKAMDANMGDEGP4
…r-target-rules # Conflicts: # src/generated/docs-content.ts
This was referenced Nov 29, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds per-target rule selection: an
includelist in a target'srulesfeature options (object form oftargets). A target withincludereceives only the named rules, local and fetched (.rulesync/rules/.curated/) alike, so fetched rules can be routed per tool without editing their frontmatter, whichrulesync installrewrites.What changed
RulesProcessor.loadRulesyncFilesnarrows the merged rules (all input roots, local + curated) by theincludeoption before the usual root/target handling.sources[].rulesmatches (reusesnormalizeRuleFilterName/isWildcardSelection): file name without.md(.mdaccepted), a nested rule by its path (frontend/react),["*"]= every rule,[]= none.generatewith an error naming the target and the names.docs/guide/configuration.md; a pointer fromdocs/guide/declarative-sources.md. The JSON schema needs no change (feature options are typed as a free-form record).Design decisions (made autonomously, can be revisited)
targetsfrontmatter still applies. A named rule whose frontmatter excludes the target is not generated, and a warning names it.includecan never add a rule to a tool the rule itself excludes.localRootrule without its root still fails as before.[]is allowed (no rules), unlikesources[].rules, where an empty list is an error because it is ambiguous with skills. Here it is not ambiguous.includesurvives--targets. Unlike other per-feature options, it is always read from the config file (getRulesFeatureOptionsinsrc/config/config.ts), sogenerate -t <target>never writes rules the target excludes. The--checkowner comparison already used the config-file options.AGENTS.md) share one selection: last target wins, as for any shared file (documented; no extra warning, since the existing fold-root overwrite watch already reports the lossy case).includetoo. It falls back to every rule when the selection is invalid, so import never fails on it.Skipped
ruleTargetsfield from the issue, by design.Closes #4016
🤖 Generated with Claude Code
https://claude.ai/code/session_01JdNNKCxxrKAMDANMGDEGP4