.claude/skills/gen-copilot-instructions/SKILL.md
Bootstrap a copilot-instructions.md for any repository by discovering the project structure, validating every command, and embedding universal architectural principles. Use this for foreign repos or non-.NET projects. For your own .NET solutions, use New-CopilotContext.ps1 instead. Invoke when the user says: create copilot instructions, bootstrap instructions file, add copilot-instructions.md, generate agent instructions for this repo, set up AI coding guidelines. Domain: DevOps, AI Context. Level: Intermediate.
npx skillsauth add klod68/littlerae gen-copilot-instructionsInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Generate a .github/copilot-instructions.md for this repository.
The output combines project-specific operational guidance (discovered from the repository) with universal architectural principles (defined below and always included verbatim). Both parts are required — do not omit either.
Success criteria: After reading the generated file, an agent should be able to:
README.md — purpose, setup, build commandsCONTRIBUTING.md — workflow, validation stepsdocs/ — architecture, conventionsCHANGELOG.md — recent major changesLocate and extract exact commands from whichever applies:
*.csproj / *.sln — .NETpackage.json — Node.jsrequirements.txt / pyproject.toml — Pythonpom.xml / build.gradle — Java/KotlinCargo.toml — Rustgo.mod — GoGemfile — RubyMakefile / scripts/ / build/ / tools/Read the exact commands the pipeline runs — these are the ground truth for what "passing" means:
.github/workflows/*.ymlazure-pipelines.yml.circleci/config.yml.gitlab-ci.ymlJenkinsfile.eslintrc*, .prettierrc*, tsconfig.json, .editorconfigDockerfile, docker-compose.yml.nvmrc, .python-version, .ruby-versionsrc/, lib/, app/)test/, tests/, __tests__/, spec/)main.*, index.*, Program.*)Run each command before documenting it. Start from a clean state:
git clean -fdx
Mark each result:
| Symbol | Meaning | |---|---| | ✅ | Succeeds | | ❌ | Fails — document error + workaround | | ⚠️ | Gotcha / non-obvious prerequisite | | ⏱️ | Slow (>30 s) — note expected duration | | 🔄 | Order-dependent |
Test these scenarios (not edge cases — these are the common failure modes):
Document any of the following if present:
Use the output template below. Translate the architectural principles to match the project's language and idioms. Do not omit, summarize, or move any principle section to a separate document.
Writing style:
# `{ProjectName}` — Copilot Instructions
## What This Is
{One sentence. What does this project do and why does it exist?}
## Prerequisites
- {Runtime/SDK name} {exact version}
- {Tool} {exact version}
- ⚠️ {Any non-obvious prerequisite}
## Setup & Build
\`\`\`bash
# Setup
{command}
# Build
{command}
# Test
{command}
# Lint / Format
{command}
\`\`\`
| Command | Status | Notes |
|---|---|---|
| `{command}` | ✅ / ❌ / ⚠️ | {notes} |
## Project Structure
| Path | Purpose |
|---|---|
| `{path}` | {purpose} |
## Where to Make Changes
- {feature or behavior} → `{path}`
- {feature or behavior} → `{path}`
## Common Pitfalls
- ⚠️ {Pitfall}: {How to avoid}
- 🔄 {Order requirement}: {Why}
## CI Checks — Replicate Locally
\`\`\`bash
{exact commands CI runs}
\`\`\`
---
## Architectural Rules
### Class & Interface Design
- Depend on abstractions. Never depend on concrete implementations across module or library boundaries.
- A class has exactly one reason to change. If it has more, split it.
- Extend behavior by adding new implementations, not by modifying existing ones.
- Subtypes must be substitutable for their base type. Consumers never check the concrete type.
- Interfaces are small and role-focused. An interface with many unrelated methods must be split.
- Concrete classes are internal details. Public API surface is interfaces, abstract types, and stateless helpers.
### Dependency & Instantiation
- Never use `new ConcreteType()` to instantiate a type from another module or library. Use factories or DI.
- Dependencies enter via constructor injection as abstractions.
- DI registrations for external types use factory delegates, not hard-coded constructors.
- Each module/package exposes one registration entry point and manages its own internal wiring.
### Function Shape (CQS)
- **Commands** — return void/Task, use imperative verbs (`Save`, `Delete`, `Execute`). No data returned.
- **Queries** — return a result, use `Get`/`Find`/`Load`. No side effects.
- **Validators** — return bool, use `Is`/`Has`/`Can`. No side effects.
- A function that does two things must be split into two functions.
### Preconditions & Contracts
- Every public function validates all inputs at entry. Violations throw immediately with a clear error.
- Assert postconditions when the result contract is non-obvious.
### Async & Concurrency
- All I/O is async. Never block a thread waiting for async results (no `.Result`, `.Wait()`).
- Do not capture sync context in library code (`ConfigureAwait(false)` or equivalent).
- Always accept and propagate cancellation tokens. Never substitute an empty token for a provided one.
- Never fire-and-forget (`async void` or unmanaged background tasks).
### Nullability & Absence
- Null must be explicit in all type signatures.
- Never return null for a collection. Return empty.
- Nullable suppression requires an inline comment.
### Error Handling
- Contract violations (programming errors): propagate immediately, do not catch.
- Infrastructure failures: catch at the boundary, enrich, wrap in a domain exception, propagate once.
- Never swallow exceptions silently.
- Use result types for expected domain outcomes; use exceptions for broken contracts. Never mix in the same return path.
- Wrap all infrastructure exceptions before they cross the public API. Preserve the original as inner cause.
### Observability
- Every significant operation emits: a trace span, a duration metric, and a structured log on failure.
- Use structured logging with templates. No string interpolation in log messages.
- Never include sensitive data in traces, metrics, or logs.
### Versioning
- MAJOR: any breaking API change. MINOR: new backward-compatible feature. PATCH: bug fix only.
- Deprecate before removing. Deprecated members survive at least one MINOR release.
- Every release has a CHANGELOG entry.
### Testing
- Unit tests mock all dependencies via abstractions.
- Name tests: `MethodOrUnit_Condition_ExpectedOutcome`.
- Every public method: one happy-path test + one test per guard clause.
- Integration tests use on-demand provisioned infrastructure. Never shared state.
- Integration tests run in a separate suite from unit tests.
### Common Anti-Patterns — Reject in Code Review
| Anti-Pattern | Fix |
|---|---|
| `new ConcreteType()` across module boundaries | Factory or DI |
| `switch`/`if-else` branching on type | Polymorphism |
| `is`/`instanceof` check on base type | Redesign |
| Empty `catch {}` | Re-throw, wrap, or log |
| Async without cancellation token | Add cancellation parameter |
| Blocking on async (`.Result`, `.Wait()`) | Await properly |
| Returning `null` for collection | Return empty collection |
| Command that returns data | Split into command + query |
| Interface with many unrelated methods | Split by role |
| Public concrete non-abstract class | Make `internal` or `abstract` |
---
## Instructions for AI Agents
Trust these instructions. Search the codebase only when:
1. These instructions are incomplete for the specific task.
2. You need the concrete signature of an existing internal method.
When generating code, verify it satisfies every rule in **Architectural Rules** before
emitting. If a user request conflicts with a rule, flag the conflict and propose a
compliant alternative.
tools
Use when cross-cutting concerns (logging, metrics, validation, authorization) are tangled into command handlers or service methods, when building database command pipelines with reorderable concerns, or when HTTP client pipelines or message handlers need composable, independently-replaceable processing stages. Covers ICommandInterceptor interface, InterceptorPipeline with reverse-chain construction, zero-cost Empty sentinel to skip overhead when no interceptors are registered, and ConfigureAwait(false) discipline for library code. Domain: Architecture, Cross-Cutting Concerns. Level: Intermediate. Tags: interceptor, pipeline, middleware, decorator, cross-cutting-concerns.
development
Use when writing integration tests for Razor Pages, MVC, or Minimal API applications to validate routing, middleware, page rendering, and HTTP behavior without a browser or live server, or when adding fast smoke tests to a CI pipeline. Covers WebApplicationFactory<Program> setup with public partial class Program, in-memory test server, AngleSharp HTML parsing, CSS selector assertions, redirect and status code testing, and a shared static fixture pattern for minimal per-test startup overhead. Domain: Testing, ASP.NET Core. Level: Intermediate. Tags: integration-testing, webapplicationfactory, razor-pages, anglesharp, http-testing.
development
Use when designing indexes for new tables, diagnosing slow queries that are not using indexes efficiently, reviewing index fragmentation and maintenance, or when the current indexing strategy results in key lookups, table scans, or missing index warnings. Covers clustered index key selection (narrow, unique, ever-increasing), non-clustered index design for query patterns, covering indexes with INCLUDE columns, filtered indexes for subset queries, composite index column ordering, DMV-based monitoring for missing and unused indexes, and rebuild vs reorganize maintenance thresholds. Domain: Database, Performance. Level: Intermediate. Tags: index, sql-server, covering-index, filtered-index, performance, dmv, maintenance.
development
Use when building a searchable in-memory catalog or registry for documentation sites, admin panels, or type/API browsers where you need keyword matching, fuzzy search, and ranked results without an external search engine or database. Covers RegistryService with weighted scoring across name, description, keywords, and method names; Levenshtein fuzzy matching; synonym expansion; category and subcategory filtering; and singleton DI registration for datasets of hundreds to low thousands of items. Domain: Search, Data Access Patterns. Level: Intermediate. Tags: search, registry, fuzzy-matching, in-memory, catalog, filtering.