katas-path-conditional-rules

Classifies repository rules as universal or path-conditional and rewrites CLAUDE.md with glob-scoped imports.

Updated Jun 28, 2026
One-click install
npx skills add https://github.com/JaviMontano/claude-plugins --skill katas-path-conditional-rules-javimontano
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: katas-path-conditional-rules
Source: https://github.com/JaviMontano/claude-plugins/tree/main/plugins/claude-native-toolkit/skills/katas-path-conditional-rules
Command: npx skills add https://github.com/JaviMontano/claude-plugins --skill katas-path-conditional-rules-javimontano

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Monolithic CLAUDE.md files load every rule (Python style, Terraform conventions, testing, security) into every session, wasting thousands of context tokens even when the agent only edits a README. This Skill separates always-loaded universal rules from language heuristics that activate only for matching file paths. ## Core Features & Use Cases - Rule classification: Marks each rule as universal (security policies, loaded directly without a glob) or conditional (language heuristics scoped to globs like src/**/*.py or *.tf). - CLAUDE.md restructuring: Produces a rewritten CLAUDE.md with direct imports for universal rules and ## When editing <glob>: blocks for conditional ones, while clarifying that real runtime activation uses skill paths: frontmatter or path-aware hooks. - Measurable token savings: Estimates context savings by comparing input_tokens when editing a README versus editing a .py file, and resolves conflicts via subpath precedence. - Use Case: A monorepo with Python in src/ and Terraform in infra/ loads 2000 lines of rules on every edit; this Skill reclassifies them so editing the README loads only the ~120-token security policy. ## Quick Start Ask the agent to audit the repository's CLAUDE.md, classify each rule as universal or conditional by path glob, and produce the rewritten CLAUDE.md with an estimated token savings.

Frequently Asked Questions about katas-path-conditional-rules

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I make CLAUDE.md rules load only for specific file paths?▼

Path-conditional loading uses the `paths:` frontmatter of a skill (e.g., `paths: ["src/**/*.py"]`) or a path matcher in a PreToolUse hook. The `## When editing <glob>:` heading inside CLAUDE.md is only an organizational convention, not an automatic runtime loader.

Which rules should always be loaded in CLAUDE.md?▼

Security policies should be universal: imported directly in the root CLAUDE.md with no glob so they apply to every edit. Language heuristics like style, lints, and testing conventions should be conditional, scoped to globs such as `src/**/*.py` or `*.tf`.

Does '## When editing' in CLAUDE.md automatically unload rules?▼

No. That heading is a structural convention for organizing rules, not a runtime mechanism. Automatic activation by path requires skill `paths:` frontmatter, explicit imports via `.claude/rules/`, or a path-aware hook matcher.

What happens when two glob rules match the same file?▼

Both matching rule sets load, and the more specific subpath wins on point conflicts. For example, if `src/**/*.py` and `src/payments/**/*.py` both match, the deeper payments rule takes precedence in conflicts.

How do I measure token savings from conditional rules?▼

Compare `input_tokens` per turn between a session editing a README and one editing a `.py` file. A README edit should load only universal rules, while the Python edit additionally loads the glob-matched language heuristics.

When should I not use path-conditional rules?▼

Avoid them for security policies, which must always load, and for tasks unrelated to repository rule structure, such as writing application code. Also avoid overly broad globs that reload rules on unexpected files.