---
name: setup-copilot
description: Use when the user wants to generate a .github/copilot-instructions.md file for the current project so Visual Studio Copilot automatically follows team coding standards. Triggered by phrases like "generate copilot instructions", "set up copilot", or "create copilot file".
---

<context>
# Generate Copilot Instructions

## Overview

Reads all skills from the SkillsOfTheKraken repo, distills each into Copilot-friendly rules, and writes `.github/copilot-instructions.md` to the current project. Once committed, Visual Studio and VS Code Copilot enforce the same standards automatically.
</context>

<task>
### 1 — Fetch all skills from the repo

```powershell
$repo   = "SeayMonster/SkillsOfTheKraken"
$skills = gh api repos/$repo/contents/skills --jq '.[].name'

$contents = @{}
foreach ($skill in $skills) {
    $raw = gh api repos/$repo/contents/skills/$skill/SKILL.md --jq '.content' |
           ForEach-Object { [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($_)) }
    $contents[$skill] = $raw
}
```

### 2 — Distill each skill into Copilot instructions

For each skill, read its content and extract rules that Copilot can apply when writing or reviewing code. 

**Include skills that define:**
- Coding style, patterns, naming conventions
- Architecture rules, class/method structure
- Database access patterns
- Logging conventions
- Technology-specific patterns (C#, SQL, VB, etc.)

**Skip skills that are Claude Code workflow only** (no coding rules):
- Skills about pinning projects, adding to PM, generating docs
- Skills about skill creation or Claude configuration
- Skills that only describe when to invoke a tool

### 3 — Write the file

Create `.github/copilot-instructions.md` in the current working directory:

```powershell
$outDir  = Join-Path (Get-Location).Path ".github"
$outFile = Join-Path $outDir "copilot-instructions.md"
if (-not (Test-Path $outDir)) { New-Item -ItemType Directory -Path $outDir | Out-Null }
```

Format the file as:

```markdown
# Copilot Instructions
<!-- Generated by crisp-dev-copilot-instructions skill. Re-run to update. -->

## [Skill Name]
[Direct rules distilled from the skill — imperative, specific, actionable]
- Rule 1
- Rule 2

## [Next Skill Name]
...
```

Write rules as **direct imperatives** ("Use X", "Always Y", "Never Z") — not as descriptions of what the skill does.

### 4 — Confirm

Tell the user:
> "Written to `.github/copilot-instructions.md`. Commit it and Copilot will follow these rules in Visual Studio and VS Code automatically."
</task>

<constraints>
## Notes

- Safe to re-run — overwrites the file with the latest skills from the repo
- The file should be committed to the repo so teammates get it on pull
- Only coding-relevant rules are included — Claude workflow skills are skipped
</constraints>
