copilot
Copilot instructions54 starsChanged 3 months agoMITView on GitHub
Monorepo containing Nav's GitHub Copilot ecosystem tools: All applications deployed on NAIS platform with environment-specific configurations. Security architecture: See SECURITY.md for trust zones, auth flow, and secret isolation. These standards apply across Nav projects. Project-specific guidelines follow below. When fixing a bug or implementing a feature, change only what is necessary. Do not rename variables, restructure working code, or refactor beyond the task at hand. Keep diffs small and focused so they are easy to review. Based on GitHub's analysis…
In this repository35 other files it gives its agents.
- AGENTS.mdAGENTS.md
- ai-news-researchSkill
- aksel-builderSkill
- aksel-spacingSkill
- api-designSkill
- conventional-commitSkill
- deliberate-ai-useSkill
- flyway-migrationSkill
- jackson-3-migrationSkill
- java-to-kotlinSkill
- kafkaSkill
- klarsprakSkill
- kotlin-app-configSkill
- ktor-scaffoldSkill
- naisSkill
- nav-architecture-reviewSkill
- nav-authSkill
- nav-deep-interviewSkill
- nav-dekoratorenSkill
- nav-planSkill
- nav-troubleshootSkill
- observability-debuggingSkill
- observability-setupSkill
- playwright-testingSkill
- postgresql-reviewSkill
- readme-reviewSkill
- rust-developmentSkill
- security-owaspSkill
- security-reviewSkill
- spring-boot-scaffoldSkill
- terse-modeSkill
- threat-modelSkill
- tokenx-authSkill
- web-design-reviewerSkill
- workstation-securitySkill
The file
Show its rules and text
We split this copilot-instructions.md into the rules it gives an agent
14 rules. About 0 are common, 8 are distinctive, and 6 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈8
Distinctive · estimate
This author's own choices. Worth a look.
6
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 13
All applications deployed on NAIS platform with environment-specific configurations.
- Distinctive: line 42
When fixing a bug or implementing a feature, change only what is necessary.
- Distinctive: line 53
CRITICAL: Always use Aksel spacing tokens, never Tailwind padding/margin
- Distinctive: line 105
Commands early: Put executable commands near the top, not buried at the bottom
- Distinctive: line 186
CRITICAL: Always use Nav DS spacing tokens, never Tailwind padding/margin utilities.
- Very specific: line 211
Run: pnpm test in apps/my-copilot
- Distinctive: line 270
Error responses: never leak upstream error details to clients
- Very specific: line 416
Use {{domain_internal}} and {{domain_external}} in allowlist.json for environment-specific URLs:
- Distinctive: line 437
When working across applications:
- Very specific: line 440
Change directory: Use cd apps/{app-name} before running commands
- Very specific: line 441
Use mise tasks: All apps support mise commands (preferred)
- Very specific: line 442
Verify changes: Always run mise check after making changes
- Distinctive: line 443
Reference paths: Use workspace-relative paths from repo root
- Very specific: line 465
IMPORTANT: After making any code or documentation changes, run mise all from the repository root to build and verify all applications:
≈ “Common” is an estimate: at least 1 in 5 of the 1,644 Copilot instructions files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Copilot Instructions for navikt/copilot
Repository Overview
Monorepo containing Nav's GitHub Copilot ecosystem tools:
- my-copilot - Self-service portal for managing Copilot subscriptions (Next.js 16)
- copilot-api - Backend API for Copilot data and seat management (Go)
- copilot-metrics - Naisjob that populates BigQuery with daily Copilot usage metrics (Go)
- mcp-onboarding - Reference MCP server with GitHub OAuth (Go)
- mcp-registry - Public registry for Nav-approved MCP servers (Go)
All applications deployed on NAIS platform with environment-specific configurations.
Security architecture: See SECURITY.md for trust zones, auth flow, and secret isolation.
Nav Development Standards
These standards apply across Nav projects. Project-specific guidelines follow below.
Nav Principles
- Team First: Autonomous teams with circles of autonomy, supported by Architecture Advice Process
- Product Development: Continuous development and product-organized reuse over ad hoc approaches
- Essential Complexity: Focus on essential complexity, avoid accidental complexity
- DORA Metrics: Measure and improve team performance using DevOps Research and Assessment metrics
Nav Tech Stack
- Backend: Kotlin with Ktor, PostgreSQL, Apache Kafka
- Frontend: Next.js 16+, React, TypeScript, Aksel Design System
- Platform: Nais (Kubernetes on Google Cloud Platform)
- Auth: Azure AD, TokenX, ID-porten, Maskinporten
- Observability: Prometheus, Grafana Loki, Tempo (OpenTelemetry)
Nav Code Standards
Minimal Editing
When fixing a bug or implementing a feature, change only what is necessary. Do not rename variables, restructure working code, or refactor beyond the task at hand. Keep diffs small and focused so they are easy to review.
Kotlin/Ktor Patterns
- ApplicationBuilder pattern for bootstrapping
- Sealed classes for environment configuration (Dev/Prod/Local)
- Kotliquery with HikariCP for database access
- Rapids & Rivers pattern for Kafka event handling
Next.js/Aksel Requirements
- CRITICAL: Always use Aksel spacing tokens, never Tailwind padding/margin
- Mobile-first with responsive props:
xs,sm,md,lg,xl - Norwegian number formatting with space separators
Nais Deployment
- Manifests in
.nais/directory - Required endpoints:
/isalive,/isready,/metrics - OpenTelemetry auto-instrumentation for observability
Writing Effective Agents
Based on GitHub's analysis of 2,500+ repositories, follow these patterns when creating or updating agents in .github/agents/:
Structure (in order):
- Frontmatter - Name and description in YAML
- Persona - One sentence: who you are and what you specialize in
- Commands - Executable commands early, with flags and expected output
- Related Agents - Table of agents to delegate to
- Core Content - Code examples over explanations (show, don't tell)
- Boundaries - Three-tier system at the end
Six Core Areas to Cover:
- Commands (with flags and options)
- Testing patterns
- Project structure
- Code style (✅ Good / ❌ Bad examples)
- Git workflow
- Boundaries
Three-Tier Boundaries:
## Boundaries
### ✅ Always
- Run `mise check` after changes
- Use parameterized queries
### ⚠️ Ask First
- Modifying production configs
- Changing auth mechanisms
### 🚫 Never
- Commit secrets to git
- Skip input validationKey Principles:
- Commands early: Put executable commands near the top, not buried at the bottom
- Code over prose: Show real code examples, not descriptions of what code should do
- Specific stack: Include versions (
Next.js 16,Go 1.26,Kotlin 2.0) - Actionable boundaries: "Never commit secrets" not "I cannot access secrets"
Application-Specific Guidelines
apps/my-copilot (Next.js + TypeScript)
Self-service portal for managing GitHub Copilot subscriptions. Next.js 16 app with Azure AD authentication.
Commands
Working directory: apps/my-copilot
Run after all changes: mise check
Available tasks:
mise check- Run all checks (ESLint, TypeScript, Prettier, Knip, Vitest)mise test- Run Vitest testsmise dev- Start Next.js dev server (http://localhost:3000)
Tech Stack
- Next.js 16 with App Router
- TypeScript strict mode
- Nav Design System (@navikt/ds-react)
- Tailwind CSS v4.1
- Octokit for GitHub API
- BigQuery for usage analytics (via @google-cloud/bigquery)
- Vitest for testing
File Structure
apps/my-copilot/src/
├── app/ # Next.js App Router pages
│ ├── api/ # API routes for Copilot data
│ ├── usage/ # Analytics dashboard
│ └── overview/ # License management
├── components/ # Reusable React components
└── lib/ # Utilities and business logic
├── auth.ts # Azure AD JWT validation
├── github.ts # GitHub API client (Octokit)
├── bigquery.ts # BigQuery client for usage metrics
├── cached-bigquery.ts # Cached BigQuery queries
└── data-utils.ts # Data aggregationKey Patterns
Authentication:
const user = await getUser(); // redirects if not auth
const user = await getUser(false); // returns null if not authAPI Routes:
// ✅ Explicit error handling
export async function GET() {
const { usage, error } = await getCachedBigQueryUsage();
if (error) return NextResponse.json({ error }, { status: 500 });
return NextResponse.json(usage);
}Number Formatting:
import { formatNumber } from "@/lib/format";
formatNumber(151354); // "151 354" (Norwegian locale)Spacing Rules - Mobile-First Design
CRITICAL: Always use Nav DS spacing tokens, never Tailwind padding/margin utilities.
// ✅ Good - Nav DS Box with responsive padding
<main className="max-w-7xl mx-auto">
<Box
paddingBlock={{ xs: "space-16", md: "space-24" }}
paddingInline={{ xs: "space-16", md: "space-40" }}
>
{children}
</Box>
</main>
// ❌ Bad - Tailwind utilities
<main className="p-4 mx-4">Responsive breakpoints: xs (0px), sm (480px), md (768px), lg (1024px), xl (1280px)
Common spacing tokens: space-8, space-16, space-24, space-32, space-40
Testing
- Framework: Vitest with TypeScript
- Location:
*.test.tsfiles next to source - Run:
pnpm testinapps/my-copilot - Focus on
lib/utilities
Boundaries
✅ Always: Use Nav DS spacing tokens, run mise check after all changes, TypeScript strict mode
⚠️ Ask first: Auth changes, GitHub API modifications, data aggregation changes
🚫 Never: Tailwind p-/m- utilities, commit secrets, skip type checking
apps/copilot-api (Go + Backend API)
Backend API that holds all external service credentials (GitHub App, BigQuery). See SECURITY.md for the full security architecture.
Commands
Working directory: apps/copilot-api
Run after all changes: mise check
Available tasks:
mise check- Run all checks (fmt, vet, staticcheck, lint, test)mise test- Run tests with verbose outputmise dev- Run with DEBUG logging (http://localhost:8080)
Tech Stack
- Go with standard library
- Azure AD JWT validation (JWKS + azp)
- BigQuery client for usage analytics
- GitHub App authentication (installation tokens)
- Prometheus metrics (background collection)
Architecture
my-copilot (BFF) → OBO token → copilot-api → GitHub API / BigQueryKey Files
auth.go— Azure AD JWT validation, JWKS cache, azp check, auth middlewaregithub.go— GitHub App auth, installation tokens, billing/seat/SAMLgithub_handlers.go— HTTP handlers for seat managementbigquery.go— BigQuery queries + cached wrapperbigquery_handlers.go— HTTP handlers for BigQuery datahandlers.go— Router, middleware chain, RFC 7807 errorsmain.go— Server setup, graceful shutdownmetrics.go— Prometheus metrics with background collectionconfig.go— Environment configcache.go— In-memory TTL cache
Security Boundaries
- All
/api/v1/routes require Azure AD OBO token with validazp /health,/ready,/metricsare public (pod-level, not exposed via ingress)- Input validation uses regex for GitHub usernames, MaxBytesReader for request bodies
- Error responses never leak upstream error details to clients
- Secrets come from Nais Secrets (
envFrom), never hardcoded
Boundaries
✅ Always: Validate azp claim, parameterize queries, log mutations with actor, run mise check
⚠️ Ask first: Auth mechanism changes, network policy changes, new outbound rules
🚫 Never: Log PII at INFO+, forward raw errors to clients, bypass azp validation
apps/mcp-onboarding (Go + MCP)
Reference MCP server demonstrating GitHub OAuth authentication for VS Code integration.
Commands
Working directory: apps/mcp-onboarding
Run after all changes: mise check
Available tasks:
mise check- Run all checks (fmt, vet, staticcheck, lint, test)mise test- Run tests with verbose outputmise dev- Run with DEBUG logging (http://localhost:8080)
Tech Stack
- Go with standard library
- OAuth 2.1 with PKCE
- MCP JSON-RPC protocol
- Streamable HTTP transport
Architecture
VS Code (MCP Client) ←→ mcp-onboarding (OAuth + MCP Server) ←→ GitHub OAuthFlow:
- VS Code discovers OAuth metadata via
/.well-known/oauth-authorization-server - User authenticates via GitHub
- Server validates org membership and issues access token
- VS Code uses token to call MCP tools
Available MCP Tools
hello_world- Returns greeting with authenticated GitHub usernamegreet- Personalized greeting messagewhoami- Authenticated user informationecho- Echo back messageget_time- Current server time
Configuration
| Variable | Description | Default |
PORT | Server port | 8080 |
BASE_URL | Public URL for OAuth redirects | http://localhost:8080 |
GITHUB_CLIENT_ID | GitHub OAuth App client ID | (required) |
GITHUB_CLIENT_SECRET | GitHub OAuth App client secret | (required) |
ALLOWED_ORGANIZATION | Required GitHub org membership | navikt |
LOG_LEVEL | Log level | INFO |
Key Files
main.go- Application entry pointoauth.go- OAuth 2.1 + PKCE implementationmcp.go- MCP JSON-RPC protocol handlersgithub.go- GitHub API integration
Boundaries
✅ Always: Run mise check after all changes, validate OAuth flow, test org membership
⚠️ Ask first: OAuth implementation changes, MCP protocol updates
🚫 Never: Commit secrets, skip security validation, bypass org checks
apps/mcp-registry (Go + Public API)
Public registry service for Nav-approved MCP servers, implementing MCP Registry v0.1 specification.
Commands
Working directory: apps/mcp-registry
Run after all changes: mise check
Available tasks:
mise check- Run all checks (fmt, vet, staticcheck, lint, test)mise test- Run tests with verbose outputmise validate- Validate allowlist.json by starting servermise dev- Run with DEBUG logging (http://localhost:8080)
Tech Stack
- Go with standard library
- MCP Registry v0.1 specification
- JSON Schema validation
- Prometheus metrics
Configuration
| Variable | Description | Default |
PORT | Server port | 8080 |
LOG_LEVEL | Log level | INFO |
LOGGED_ENDPOINTS | Endpoints to log | /,/v0.1/servers |
DOMAIN_INTERNAL | Internal domain for templates | intern.dev.nav.no |
DOMAIN_EXTERNAL | External domain for templates | ekstern.dev.nav.no |
API Endpoints
| Endpoint | Description |
GET / | Service information |
GET /v0.1/servers | List all MCP servers |
GET /v0.1/servers/{name}/versions/{version} | Get specific server |
GET /v0.1/servers/{name}/versions/latest | Get latest server version |
GET /health | Health check |
GET /ready | Readiness check |
GET /metrics | Prometheus metrics |
Note: Server names with / must be URL-encoded (e.g., io.github.navikt/github-mcp → io.github.navikt%2Fgithub-mcp)
Key Files
main.go- Application entry point and routinghandlers.go- HTTP request handlersconfig.go- Configuration and environment loadingvalidation.go- allowlist.json validationtypes.go- Data structuresallowlist.json- Registry data (MCP Server JSON Schema)
Server Name Format
Reverse-DNS with exactly one /:
- Format:
{namespace}/{name}(e.g.,io.github.navikt/github-mcp) - Pattern:
^[a-zA-Z0-9][a-zA-Z0-9.-]*[a-zA-Z0-9]/[a-zA-Z0-9][a-zA-Z0-9._-]*[a-zA-Z0-9]$
Domain Templates
Use {{domain_internal}} and {{domain_external}} in allowlist.json for environment-specific URLs:
{
"remotes": [{
"type": "streamable-http",
"url": "https://my-server.{{domain_internal}}/mcp"
}]
}Boundaries
✅ Always: Validate allowlist.json with mise validate, run mise check after all changes, follow MCP spec
⚠️ Ask first: Registry format changes, validation rules, API endpoints
🚫 Never: Bypass security validation, skip schema validation, modify spec compliance
Monorepo Navigation
When working across applications:
- Check context: Determine which app the request relates to
- Change directory: Use
cd apps/{app-name}before running commands - Use mise tasks: All apps support
misecommands (preferred) - Verify changes: Always run
mise checkafter making changes - Reference paths: Use workspace-relative paths from repo root
Example workflow:
# Working on my-copilot
cd apps/my-copilot
mise check
# Working on mcp-registry
cd apps/mcp-registry
mise validate # validate allowlist.json
mise check
# Back to root
cd ../..Build and Verify
IMPORTANT: After making any code or documentation changes, run mise all from the repository root to build and verify all applications:
mise allThis runs all checks across all applications to ensure nothing is broken.
Running the nav-pilot binary
nav-pilot writes to ~/.copilot/, ~/.nav-pilot/ and the repository you are
standing in. Never run it — or a test that calls run() — against a real home
directory. Set HOME to a temporary directory (nav-pilot does not read
COPILOT_HOME), along with NAV_PILOT_CONFIG and XDG_CONFIG_HOME, and check
~/.copilot and ~/.nav-pilot afterwards for changes you did not intend. In Go
tests, use isolatedConfig(t).
Isolation that is set up wrong looks exactly like isolation until someone checks.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

