A powerful CLI application for building GitHub Copilot instruction files from modular, hierarchical components. Create sophisticated instruction sets using a three-tier architecture: Base Instructions β Domain-Specific Layers β Task-Specific Modules.
- Hierarchical Module System: Compose instructions from base, domain, and task-specific modules
- Smart Dependency Resolution: Automatic dependency management with cycle detection
- Intelligent Conflict Resolution: Handle module conflicts with multiple resolution strategies
- Advanced Merging: Smart content merging with semantic understanding
- Template Variables: Dynamic content generation with variable substitution
- Conditional Instructions: Include/exclude sections based on context and conditions
- Priority-Based Ordering: Sophisticated priority calculation for optimal instruction ordering
- Interactive CLI: Both command-driven and configuration-driven workflows
- Performance Optimized: Caching, lazy loading, and parallel processing
npm install -g copilot-instructionscopilot-instructions init# Build with specific modules
copilot-instructions build --base programming-fundamentals --domain frontend/react --task ui-components
# Build from configuration file
copilot-instructions build
# Build specific profile
copilot-instructions build --profile production# List all modules
copilot-instructions list
# Filter by type and tags
copilot-instructions list --type domain --tags react,frontendBase Instructions (Foundation)
β
Domain Layers (Technology-specific)
β
Task Modules (Use case-specific)
β
.copilot-instructions.md (Output)
- Base Instructions: General programming principles, code quality, documentation standards
- Domain Layers: Technology-specific guidance (React, Node.js, Python, etc.)
- Task Modules: Specific use cases (API development, UI components, testing, etc.)
copilot-instructions-builder/
βββ src/
β βββ core/ # Core composition engine
β β βββ composer.js # Main instruction composition
β β βββ resolver.js # Dependency resolution
β β βββ conflict-resolver.js # Conflict handling
β β βββ ...
β βββ modules/ # Module management
β βββ commands/ # CLI commands
β βββ utils/ # Utilities and helpers
βββ modules/ # Built-in instruction modules
β βββ base/ # Foundation modules
β βββ domains/ # Technology-specific modules
β βββ tasks/ # Use case modules
βββ templates/ # Output templates
# Initialize project configuration
copilot-instructions init
# List available modules
copilot-instructions list [--type base|domain|task] [--tags react,frontend]
# Build instructions from modules
copilot-instructions build --base programming-fundamentals --domain frontend/react --task ui-components
# Add module to existing config
copilot-instructions add frontend/vue
# Validate configuration
copilot-instructions validate
# Show module dependencies
copilot-instructions deps frontend/react
# Search modules
copilot-instructions search "api development"# Build from configuration file
copilot-instructions build
# Build specific profile
copilot-instructions build --profile production
# Use custom config file
copilot-instructions build --config ./configs/backend.config.js
# Build all profiles
copilot-instructions build --all-profilesEach instruction module follows a standardized JSON format:
{
"id": "module-identifier",
"name": "Module Display Name",
"type": "base|domain|task",
"version": "1.0.0",
"dependencies": ["required-module-ids"],
"conflicts": ["conflicting-module-ids"],
"tags": ["react", "frontend", "ui"],
"priority": 100,
"metadata": {
"description": "Module description",
"author": "author-name",
"category": "frontend|backend|testing|devops|general"
},
"instructions": {
"sections": [
{
"id": "section-identifier",
"title": "Section Title",
"priority": 100,
"merge_strategy": "replace|append|prepend|smart_merge",
"content": ["instruction 1", "instruction 2"],
"conditions": {
"include_if": ["tag1", "tag2"],
"exclude_if": ["tag3"],
"require_modules": ["module-id"]
}
}
]
},
"variables": {
"projectName": "{{PROJECT_NAME}}",
"framework": "{{FRAMEWORK}}"
}
}- Cycle Detection: Prevents circular dependencies with detailed error reporting
- Topological Sorting: Ensures correct module loading order
- Conflict Detection: Identifies and resolves module conflicts automatically
- Content-Aware: Understands different types of content (rules, examples, guidelines)
- Deduplication: Removes duplicate instructions automatically
- Priority-Based: Respects module and section priorities during merging
{
"variables": {
"projectName": "{{PROJECT_NAME}}",
"framework": "{{FRAMEWORK || 'React'}}"
}
}Supports:
- Simple variables:
{{VAR}} - Default values:
{{VAR || 'default'}} - Function calls:
{{func(args)}}
{
"conditions": {
"include_if": ["react", "frontend"],
"exclude_if": ["vue"],
"require_modules": ["base-frontend"],
"conflict_with": ["legacy-module"]
}
}Create a copilot-instructions.config.js file:
module.exports = {
profiles: {
development: {
modules: ['programming-fundamentals', 'frontend/react', 'ui-components'],
variables: {
PROJECT_NAME: 'My App',
FRAMEWORK: 'React',
},
},
production: {
modules: [
'programming-fundamentals',
'frontend/react',
'ui-components',
'performance-optimization',
],
},
},
output: {
file: '.copilot-instructions.md',
template: 'default',
},
};# Quick command approach
copilot-instructions build \
--base programming-fundamentals,code-quality \
--domain frontend/react \
--task ui-components,performance-optimization
# Configuration approach
copilot-instructions init
# Edit copilot-instructions.config.js
copilot-instructions build --profile frontendcopilot-instructions build \
--base programming-fundamentals,documentation \
--domain backend/nodejs \
--task api-development,database-design# Search for modules
copilot-instructions search "testing"
copilot-instructions search "performance"
# List modules by category
copilot-instructions list --type task --tags api,backend- Fork the repository
- Create a feature branch:
git checkout -b feature/new-feature - Make your changes
- Add tests for new functionality
- Run tests:
npm test - Submit a pull request
Create new modules in the modules/ directory following the module structure. See our architecture documentation for detailed guidelines.
# Run all tests
npm test
# Run specific test suites
npm run test:unit
npm run test:integration
npm run test:performanceThis project uses .env files to manage environment-specific variables.
-
.env.development: This file is for your local development environment. It should contain your actual secret keys, database URLs, etc. This file is included in.gitignoreand should not be committed to the repository. To get started, you can copy the example file:cp .env.example .env.development
Then, edit
.env.developmentwith your specific settings. -
.env.example: This file serves as a template for.env.development. It lists all the environment variables that the project expects, along with placeholder values. You can use this file as a reference to create your own.env.developmentfile. This file should be committed to the repository.
This project includes pre-configured VS Code launch configurations in .vscode/launch.json to facilitate debugging.
-
Debugging the CLI: To debug the main CLI application (
src/cli.ts), open the "Run and Debug" view in VS Code (usually accessible via the bug icon in the activity bar orCtrl+Shift+D/Cmd+Shift+D). Select the "Debug CLI" configuration from the dropdown and click the play button (Start Debugging). This will launch the CLI with the debugger attached, allowing you to set breakpoints, inspect variables, and step through the code. -
Debugging Tests: To debug Jest tests, select the "Debug Tests" configuration from the "Run and Debug" view. This configuration runs Jest with the
--runInBandoption, which is crucial for the debugger to correctly attach to the test processes. You can set breakpoints directly in your test files (*.test.ts) or in the source code being tested.
The CLI provides detailed error messages and recovery suggestions:
- Circular Dependencies: Suggests breaking changes
- Module Conflicts: Offers interactive resolution
- Invalid Configuration: Provides schema validation help
- Template Errors: Includes variable debugging information
- Lazy Loading: Modules loaded only when needed
- Incremental Builds: Only rebuild changed dependencies
- Parallel Processing: Concurrent resolution of independent modules
- Multi-level Caching: Optimized module and result caching
- Architecture Plan - Detailed technical architecture
- Configuration Guide - Configuration options and examples
- Module Development - Creating custom modules
- API Reference - Programmatic usage
- π§ Issues: GitHub Issues
- π¬ Discussions: GitHub Discussions
- π Wiki: Project Wiki
This project is licensed under the MIT License - see the LICENSE file for details.
- GitHub Copilot team for the inspiration
- Contributors and community members
- Open source projects that made this possible
Built with β€οΈ for better AI-assisted development