Generates path-specific instruction files (.github/instructions/*.md) with JIT loading via applyTo glob patterns. Performs LLM-driven repository analysis to discover file patterns and extract scope-specific rules. Use when the user requests scoped, framework-specific, or directory-specific rules for testing, components, docs, config files, or language-specific files to prevent context pollution. Works for code, documentation, configuration, and data files.
80
—
Does it follow best practices?
Impact
—
No eval scenarios have been run
Passed
No known issues
This skill generates scoped .github/instructions/*.md files that load Just-In-Time (JIT) when specific files are opened. It autonomously analyzes your repository to discover file patterns, extract scope-specific rules from existing code and documentation, and generate precise glob patterns for targeted instruction loading.
Key advantages over global instructions:
Key principle: Leverage LLM strengths for pattern discovery and rule extraction rather than manual specification.
Confirm the user wants path-specific instructions (not global).
Decision tree:
generate-repo-instructions skill instead.github/copilot-instructions.mdProceed only if creating path-specific instructions.
Goal: Understand what files/directories to target and what patterns exist.
Load the scope analysis checklist:
cat references/scope_analysis_checklist.mdWork through the checklist to discover:
Output: Clear understanding of target scope with concrete file examples.
Critical decision: Be specific or accept ambiguity?
.test.js, .spec.js, AND _test.pyGoal: Build precise applyTo glob patterns that match intended files only.
Load the pattern construction guide:
cat references/pattern_construction.mdFollow the guide to:
Example workflow:
# Test if pattern matches intended files
python3 scripts/test_glob_pattern.py --pattern "tests/**/*.py" --limit 10
# Review matches, refine if needed
python3 scripts/test_glob_pattern.py --pattern "tests/**/*.test.py" --limit 10Output: Validated glob pattern(s) for applyTo directive.
Goal: Discover scope-specific rules (not generic rules that belong in global instructions).
Load the rule discovery checklist:
cat references/rule_discovery_checklist.mdWork through the checklist to extract rules from:
Critical: Context Economics
Load references/context_economics.md to understand the Include/Exclude principle:
| ✅ Include (Scope-Specific) | ❌ Exclude (Too Generic) |
|---|---|
| "Use pytest fixtures in tests" | "Use 4 spaces for indentation" |
| "Docs must follow ADR format" | "Write clear commit messages" |
| "K8s manifests must set limits" | "Follow semantic versioning" |
Why? Path instructions have higher priority than global. Use them only for truly scope-specific rules.
Output: List of scope-specific rules with examples from the codebase.
Goal: Populate the instruction file with discovered patterns and rules.
Load template examples:
cat references/template_examples.mdChoose the appropriate template based on scope type (testing, docs, config, code).
Populate these fields:
name: Descriptive kebab-case namedescription: One-sentence scope summaryapplyTo: Validated glob pattern(s) from Step 3File naming convention:
.github/instructions/{{scope-type}}-{{content-type}}.mdpython-testing.md, api-documentation.md, kubernetes-manifests.mdrules.md)Validate the generated instruction file:
# 1. Validate YAML frontmatter and structure
python3 .github/skills/generate-agent-skills/scripts/validate_skill.py --path .github/instructions/
# 2. Verify glob pattern matches intended files
python3 .github/skills/generate-path-instructions-v2/scripts/test_glob_pattern.py \
--pattern "tests/**/*.py" \
--limit 20
# 3. Check rule specificity
# - Are all rules scope-specific?
# - Do rules include examples from actual codebase?
# - Is there any overlap with global instructions?Final checklist:
Output to user:
✅ Created: .github/instructions/{{filename}}.md
📌 Applies to: {{glob_pattern}}
📝 Summary: {{one_sentence_description}}
🧪 Tested pattern - matches {{N}} files in repoIf the user wants to refine:
Common refinements:
**/*.test.js → tests/**/*.test.js)Tests glob patterns against actual repository files.
Guides LLM through repository exploration to discover target scope.
Glob syntax reference with common patterns and anti-patterns.
Guides LLM through extracting scope-specific rules from code and docs.
Domain-specific instruction templates (testing, docs, config, code).
Explains when to use path-specific vs global instructions.
c5644f6
If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.