Generates the global repository constitution file (.github/copilot-instructions.md). Works for code repositories, documentation repositories, data repositories, and mixed repos. Performs LLM-driven deep repository analysis including docs, code patterns, build systems, documentation generators, and data schemas. Generates constitutional rules following context economics (under 1000 lines). Enforces positive constraints and no hardcoded secrets.
80
—
Does it follow best practices?
Impact
—
No eval scenarios have been run
Advisory
Suggest reviewing before use
This skill generates the global .github/copilot-instructions.md file through comprehensive LLM-driven repository analysis. It autonomously discovers project characteristics, then populates a constitutional template with discovered values.
Works for all repository types:
Key principle: Leverage LLM strengths for analysis and synthesis rather than rigid scripts.
Confirm the user wants to create the global .github/copilot-instructions.md file.
Decision tree:
generate-path-instructions skill insteadapplyTo glob patterns for targeted loadingProceed only if creating global instructions.
Perform deep codebase discovery following the checklist in references/analysis_checklist.md.
Load the analysis checklist:
cat references/analysis_checklist.mdWork through all 7 phases systematically:
Important guidelines:
Output of this step: Mental model of:
Only ask the user if you absolutely cannot determine from the codebase:
Goal: Generate 90% of instructions autonomously through analysis.
Pattern for asking:
I've analyzed the repository but need clarification on:
1. **Project description:** The README doesn't clearly state what this software does.
Can you provide a 1-2 sentence elevator pitch?
2. **Indentation:** Code samples show mixed 2-space and 4-space indentation.
What's the preferred style?If user doesn't respond: Use best judgment from majority pattern or "Follow existing code style".
Before populating the template, convert any negative rules to positive instructions.
Load the conversion patterns:
cat references/positive_constraints_patterns.mdCommon conversions:
| If You Found | Convert To |
|---|---|
"Don't use var" | "Use const or let for variable declarations" |
| "Never hardcode secrets" | "Store secrets in environment variables or key vaults" |
| "Avoid deeply nested callbacks" | "Use async/await for asynchronous flows" |
| "No trailing whitespace" | "Configure editor to trim whitespace on save" |
Validation checklist:
Load the instruction template:
cat references/instruction_template.mdPopulate all {{placeholders}} with discovered values:
| Placeholder | Source | Example |
|---|---|---|
{{repo_name}} | Auto-detect from directory name or git config | my-awesome-project |
{{elevator_pitch}} | README or user input | "A CLI tool for analyzing log files" |
{{languages}} | Detected from package.json, go.mod, etc. | "Go, TypeScript" |
{{frameworks}} | Detected from dependencies | "React, Express" |
{{build_tools}} | Detected from Makefile, package.json scripts | "npm, make" |
{{formatting_rules}} | Detected from code samples + .editorconfig | "2 spaces, Prettier enforced" |
{{test_dir}} | Detected from project structure | tests/ or __tests__/ |
{{structure_map}} | Detected directory tree with purposes | See analysis checklist |
{{build_command}} | Detected from Makefile, package.json, CI | npm run build |
{{test_command}} | Detected from package.json, Makefile | npm test |
{{lint_command}} | Detected from package.json, Makefile | npm run lint |
If a value cannot be determined:
Before writing the file, verify compliance with context economics principles.
Load the economics guide:
cat references/context_economics.mdValidation checklist:
Line count under 1000 lines (preferably under 500)
docs/ and reference themNo hardcoded secrets or credentials
Positive constraints only
High-priority information only
If validation fails: Trim content before writing.
Write the populated and validated content to .github/copilot-instructions.md.
Steps:
mkdir -p .github/.github/copilot-instructions.mdDo not ask for permission - the user already requested this in Step 1.
Provide a summary report to the user:
✅ **Repository instructions generated successfully!**
📄 **File:** `.github/copilot-instructions.md`
📊 **Line count:** 287 lines
🔧 **Tech stack detected:** TypeScript, React, Node.js
⚙️ **Build system:** npm (build, test, lint commands documented)
🎯 **Analysis sources:** README.md, package.json, 5 source files sampled
⚠️ **Reminder:** This file is always loaded into context. Review and trim if needed.
**Next steps:**
1. Review `.github/copilot-instructions.md` for accuracy
2. Test with Copilot to verify context loading
3. Create path-specific instructions for framework rules if neededThis skill uses LLM-driven analysis - no scripts required!
analysis_checklist.md
Comprehensive checklist for repository discovery. Use this to systematically analyze:
instruction_template.md
The output template with {{placeholders}} for discovered values.
context_economics.md
Guidelines for keeping instructions under 1000 lines. Explains:
positive_constraints_patterns.md
Conversion patterns for rephrasing negative rules as positive instructions. Includes:
User: "Generate repository instructions for this project"
Agent workflow:
analysis_checklist.mdnpm run build, Test: npm testsrc/ (source), tests/ (tests), docs/ (docs)positive_constraints_patterns.mdany" → "Use specific types or unknown"instruction_template.md.github/copilot-instructions.mdc5644f6
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.