Skip to content

Commit 9d2131c

Browse files
committed
Improve repo structure, CI pipeline, and contributor experience
Consolidate duplicated parsing logic into a shared module, add structural validation, harden the CI pipeline for PRs, and align all documentation with actual tooling behavior. - Extract shared parser into scripts/lib/parse-skill.js (eliminates 5x duplication) - Add scripts/validate-skills.js for frontmatter, sections, deps, and cycle detection - Add skills/skill.schema.json and skills/_template/SKILL.md.template - Add .claude/CLAUDE.md with contributor instructions - Add PR validation and version bump enforcement to CI pipeline - Auto-generate ai-plugin.json alongside agent.json - Move sitemap.xml to build-time dist/ generation (deterministic git dates) - Add requires and tags fields to all 12 skill frontmatter blocks - Remove redundant > version: body lines (frontmatter as single source of truth) - Add Setup section and generate step to CONTRIBUTING.md - Update README with Programmatic Access section and accurate usage instructions
1 parent e4f0f23 commit 9d2131c

31 files changed

Lines changed: 1036 additions & 441 deletions

File tree

.claude/CLAUDE.md

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# IC Skills — Agent Instructions for Contributors
2+
3+
This repository contains agent-readable skill files for the Internet Computer. Each skill is a single markdown file at `skills/<skill-id>/SKILL.md`.
4+
5+
## Key Rules
6+
7+
- **Never edit `src/skills-data.js`** — it is auto-generated and gitignored
8+
- **Never edit auto-generated files in `public/`**`llms.txt`, `llms-full.txt`, `.well-known/agent.json`, `.well-known/ai-plugin.json` are all regenerated from SKILL.md sources. These files ARE committed to git (not gitignored) but must only be updated by running `npm run generate`. Note: `sitemap.xml` is generated at build time into `dist/` and is NOT committed.
9+
- **Never edit `src/app.jsx` to add or update a skill** — the website auto-discovers skills from SKILL.md frontmatter. Only edit app.jsx for site-level UI changes.
10+
- **One skill = one file** at `skills/<skill-id>/SKILL.md`. No nested directories, no images, no external dependencies within a skill.
11+
- Skill IDs are **lowercase, hyphenated** (e.g., `ckbtc`, `https-outcalls`, `stable-memory`) and must match the directory name.
12+
13+
## Skill File Structure
14+
15+
Every SKILL.md has YAML frontmatter followed by a markdown body. See `skills/skill.schema.json` for the full schema and `skills/_template/SKILL.md.template` for a ready-to-copy skeleton.
16+
17+
### Required frontmatter fields
18+
`id`, `name`, `category`, `description`, `version`, `endpoints`, `status`
19+
20+
### Recommended frontmatter fields
21+
`dependencies`, `requires`, `tags` — validator warns if missing but does not block
22+
23+
### Required body sections (## headings)
24+
1. `What This Is` — 2-3 sentences
25+
2. `Prerequisites` — exact tools and versions
26+
3. `Mistakes That Break Your Build` — numbered pitfalls (highest-value section)
27+
4. `Implementation` — subsections per language (Motoko, Rust, JS)
28+
5. `Deploy & Test` — step-by-step commands
29+
6. `Verify It Works` — concrete verification commands with expected output
30+
31+
### Optional body sections
32+
- `Canister IDs` — table of external canister principals (include when skill interacts with external canisters)
33+
- `How It Works` — flow descriptions for non-trivial multi-step processes
34+
35+
## Build Commands
36+
37+
```bash
38+
npm install # Install dependencies
39+
npm run validate # Validate all skills (frontmatter, sections, deps)
40+
npm run generate # Regenerate all auto-generated files from SKILL.md sources
41+
npm run dev # Validate + generate + start Vite dev server
42+
npm run build # Validate + generate + production build
43+
```
44+
45+
## Workflow
46+
47+
After modifying any SKILL.md file, ALWAYS:
48+
1. **Bump the `version`** in frontmatter (patch for fixes, minor for new content, major for breaking changes). CI enforces this on PRs.
49+
2. Run:
50+
```bash
51+
npm run validate # Fix all errors before committing. Warnings are acceptable.
52+
npm run generate # Regenerate public/ files — commit these alongside your SKILL.md changes.
53+
```
54+
Both run in CI. Validate blocks deployment on errors. Generate output is checked for freshness — if `public/` files don't match what `npm run generate` produces, CI rejects the PR.
55+
56+
## Writing Guidelines
57+
58+
- **Write for agents, not humans.** Be explicit with canister IDs, function signatures, and error messages.
59+
- **Pitfalls prevent hallucinations.** Every pitfall documented saves agents from generating broken code.
60+
- **Code must be copy-paste correct.** Agents use code blocks directly — test everything.
61+
- **Use semver strictly.** Patch for typos, minor for new sections, major for breaking API changes.
62+
- **Keep code blocks annotated** with language identifiers (```motoko, ```rust, ```bash, etc.).
63+
64+
## Categories
65+
66+
DeFi, Tokens, Auth, Architecture, Integration, Governance, Frontend, Security, Infrastructure
67+
68+
## Project Structure
69+
70+
```
71+
skills/*/SKILL.md # Skill source files (the content)
72+
skills/skill.schema.json # JSON Schema for frontmatter
73+
skills/_template/ # Skeleton for new skills
74+
scripts/lib/parse-skill.js # Shared parsing utilities
75+
scripts/generate-*.js # Build-time generation scripts
76+
scripts/validate-skills.js # Structural validation (CI)
77+
src/app.jsx # Website (auto-discovers skills from frontmatter)
78+
public/ # Auto-generated files (committed, but never edit manually)
79+
```

.github/workflows/deploy.yml

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ name: Deploy to GitHub Pages
33
on:
44
push:
55
branches: [main]
6+
pull_request:
67
workflow_dispatch:
78

89
permissions:
@@ -11,26 +12,63 @@ permissions:
1112
id-token: write
1213

1314
concurrency:
14-
group: pages
15+
group: pages-${{ github.ref }}
1516
cancel-in-progress: true
1617

1718
jobs:
1819
build:
1920
runs-on: ubuntu-latest
2021
steps:
2122
- uses: actions/checkout@v4
23+
with:
24+
fetch-depth: 0
2225
- uses: actions/setup-node@v4
2326
with:
2427
node-version: 20
2528
cache: npm
2629
- run: npm ci
30+
- run: node scripts/validate-skills.js
31+
- name: Verify generated files are up to date
32+
run: |
33+
npm run generate
34+
git diff --exit-code public/ || {
35+
echo "::error::Generated files are out of date. Run 'npm run generate' and commit the results."
36+
exit 1
37+
}
38+
- name: Check version bumps for changed skills
39+
if: github.event_name == 'pull_request'
40+
run: |
41+
changed=$(git diff --name-only origin/${{ github.base_ref }} -- 'skills/*/SKILL.md')
42+
if [ -z "$changed" ]; then
43+
echo "No SKILL.md files changed"
44+
exit 0
45+
fi
46+
fail=0
47+
for file in $changed; do
48+
# Skip new files (no base branch version to compare)
49+
if ! git show origin/${{ github.base_ref }}:"$file" > /dev/null 2>&1; then
50+
echo "NEW: $file (no version check needed)"
51+
continue
52+
fi
53+
old_version=$(git show origin/${{ github.base_ref }}:"$file" | grep '^version:' | head -1 | awk '{print $2}')
54+
new_version=$(grep '^version:' "$file" | head -1 | awk '{print $2}')
55+
if [ "$old_version" = "$new_version" ]; then
56+
echo "::error::$file was changed but version was not bumped (still $old_version). See CONTRIBUTING.md for versioning rules."
57+
fail=1
58+
else
59+
echo "OK: $file ($old_version -> $new_version)"
60+
fi
61+
done
62+
exit $fail
2763
- run: npm run build
2864
- uses: actions/upload-pages-artifact@v3
65+
if: github.event_name != 'pull_request'
2966
with:
3067
path: dist
3168

3269
deploy:
3370
needs: build
71+
if: github.event_name != 'pull_request'
3472
runs-on: ubuntu-latest
3573
environment:
3674
name: github-pages

CONTRIBUTING.md

Lines changed: 68 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,15 @@ If you're not sure whether something is wrong, open an issue. We'd rather invest
1111

1212
---
1313

14+
## Setup
15+
16+
```bash
17+
node -v # Requires Node.js >= 20
18+
npm ci # Install dependencies
19+
```
20+
21+
---
22+
1423
## Adding a New Skill
1524

1625
### 1. Create the skill directory
@@ -19,37 +28,69 @@ If you're not sure whether something is wrong, open an issue. We'd rather invest
1928
skills/<skill-id>/SKILL.md
2029
```
2130

22-
Use a short, lowercase, hyphenated ID (e.g., `ckbtc`, `https-outcalls`, `stable-memory`).
31+
Use a short, lowercase, hyphenated ID (e.g., `ckbtc`, `https-outcalls`, `stable-memory`). The ID must match the directory name.
32+
33+
A template is available at `skills/_template/SKILL.md.template` — copy it as your starting point.
2334

2435
### 2. Write the SKILL.md file
2536

26-
Every skill file follows this structure:
37+
Every skill file has YAML frontmatter followed by a markdown body. The frontmatter is the machine-readable metadata; the body is the agent-consumable content.
2738

28-
```markdown
39+
#### Frontmatter
40+
41+
```yaml
2942
---
3043
id: <skill-id>
31-
name: Display Name
44+
name: "Display Name"
3245
category: CategoryName
33-
description: One sentence. When should an agent load this skill? What does it cover?
34-
version: 1.0.0
46+
description: "One sentence. When should an agent load this skill? What does it cover?"
3547
endpoints: 5
48+
version: 1.0.0
3649
status: stable
3750
dependencies: [dep1, dep2]
51+
requires: [icp-cli >= 0.1.0, other-tool >= version]
52+
tags: [keyword1, keyword2, keyword3]
3853
---
54+
```
3955

56+
See `skills/skill.schema.json` for the formal schema.
57+
58+
#### Frontmatter field reference
59+
60+
| Field | Required | Description |
61+
|-------|----------|-------------|
62+
| `id` | yes | Lowercase, hyphenated identifier. Must match the directory name. |
63+
| `name` | yes | Human-readable display name. |
64+
| `category` | yes | One of the predefined categories (see below). |
65+
| `description` | yes | One sentence. Describes when an agent should load this skill. |
66+
| `endpoints` | yes | Number of distinct canister methods or external API operations documented in the Implementation section. |
67+
| `version` | yes | Semantic version (`major.minor.patch`). |
68+
| `status` | yes | `stable` (production-ready) or `beta` (API may change). |
69+
| `dependencies` | recommended | Array of skill IDs this skill depends on. Use `[]` if none. |
70+
| `requires` | recommended | Tool/package dependencies with version constraints (e.g., `icp-cli >= 0.1.0`). |
71+
| `tags` | recommended | Keywords for agent discovery. Lowercase, hyphenated. |
72+
73+
#### Body sections
74+
75+
```markdown
4076
# Skill Title
41-
> version: 1.0.0 | requires: [icp-cli >= 0.1.0, other deps]
4277

4378
## What This Is
4479
Brief explanation of the technology. 2-3 sentences max.
4580

4681
## Prerequisites
4782
- Bullet list of required tools, packages, versions
4883

49-
## Mistakes That Break Your Build
50-
Numbered list of critical pitfalls. These are the most important part of the skill —
51-
they prevent agents from hallucinating incorrect patterns.
84+
## Canister IDs <!-- optional: include when skill uses external canisters -->
85+
| Environment | Canister | ID |
86+
|-------------|----------|-----|
87+
| Mainnet | ... | `...` |
88+
89+
## How It Works <!-- optional: for non-trivial multi-step flows -->
90+
### Flow Name
91+
1. Step one...
5292

93+
## Mistakes That Break Your Build <!-- HIGHEST-VALUE SECTION -->
5394
1. **Pitfall name.** Explanation of what goes wrong and why.
5495

5596
## Implementation
@@ -63,13 +104,24 @@ Step-by-step commands to deploy locally and on mainnet.
63104
Concrete commands to confirm the implementation is correct.
64105
```
65106

66-
### 3. That's it — the website auto-discovers skills
107+
### 3. Validate and regenerate
108+
109+
```bash
110+
npm run validate # Check frontmatter, sections, dependency graph
111+
npm run generate # Regenerate public/ files (llms.txt, agent.json, etc.)
112+
```
113+
114+
Both commands run automatically in CI. The deploy pipeline verifies that committed files in `public/` match what `npm run generate` produces — if they're out of date, CI will reject the PR.
115+
116+
**Commit the updated `public/` files** alongside your SKILL.md changes.
117+
118+
### 4. That's it — the website auto-discovers skills
67119

68120
The website is automatically generated from the SKILL.md frontmatter at build time. You do **not** need to edit `app.jsx` or any other source file. The build script (`scripts/generate-skills.js`) scans all `skills/*/SKILL.md` files, parses their frontmatter, and generates the data the site uses.
69121

70122
Stats (skill count, operations, categories) all update automatically.
71123

72-
### 4. Submit a PR
124+
### 5. Submit a PR
73125

74126
- One skill per PR
75127
- Include a brief description of what the skill covers and why it's needed
@@ -91,8 +143,9 @@ Stats (skill count, operations, categories) all update automatically.
91143
### Steps
92144

93145
1. Edit the `SKILL.md` content
94-
2. Bump the `version` in the SKILL.md header line: `> version: X.Y.Z | requires: [...]`
95-
3. Submit a PR with a summary of what changed
146+
2. Bump the `version` in the frontmatter
147+
3. Run `npm run validate && npm run generate` and commit the updated `public/` files
148+
4. Submit a PR with a summary of what changed
96149

97150
The website auto-generates from SKILL.md frontmatter — no need to edit any source files.
98151

@@ -103,6 +156,7 @@ The website auto-generates from SKILL.md frontmatter — no need to edit any sou
103156
- **Write for agents, not humans.** Be explicit. State exact canister IDs, exact function signatures, exact error messages.
104157
- **Pitfalls are the highest-value section.** Every pitfall you document is a hallucination prevented.
105158
- **Code must be copy-paste correct.** Agents will use your code blocks directly. Test everything.
159+
- **Annotate all code blocks** with language identifiers (` ```motoko `, ` ```rust `, ` ```bash `, etc.).
106160
- **Include canister IDs and URLs** for both local and mainnet environments.
107161
- **Keep it flat.** One file per skill. No nested directories, no images, no external dependencies.
108162
- **Use semver strictly.** Agents and tooling rely on version numbers to detect stale skills.

README.md

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,11 @@ Every skill follows the same structure:
2727

2828
| Section | Purpose |
2929
|---------|---------|
30-
| **What this is** | One paragraph. What the technology does. |
30+
| **What This Is** | One paragraph. What the technology does. |
3131
| **Prerequisites** | Exact versions. `icp-cli >= 0.1.0`, `ic-cdk >= 0.18`. |
32-
| **Mistakes that break your build** | Numbered pitfalls that prevent hallucinations. |
32+
| **Canister IDs** *(optional)* | External canister principals for mainnet/testnet. |
33+
| **How It Works** *(optional)* | Flow descriptions for multi-step processes. |
34+
| **Mistakes That Break Your Build** | Numbered pitfalls that prevent hallucinations. |
3335
| **Implementation** | Tested, copy-paste-correct code blocks. |
3436
| **Deploy & Test** | Step-by-step commands for local and mainnet. |
3537
| **Verify It Works** | Concrete commands to confirm it works. |
@@ -65,12 +67,11 @@ curl -s https://raw.githubusercontent.com/dfinity/icskills/main/skills/ckbtc/SKI
6567

6668
### Claude Code
6769

68-
Copy skills into `.claude/skills/` — they're automatically loaded into context:
70+
Fetch the raw skill and paste it into context, or use it as a custom slash command:
6971

7072
```bash
71-
mkdir -p .claude/skills/ckbtc
72-
curl -sL https://raw.githubusercontent.com/dfinity/icskills/main/skills/ckbtc/SKILL.md \
73-
> .claude/skills/ckbtc/SKILL.md
73+
# Fetch directly in conversation
74+
curl -sL https://raw.githubusercontent.com/dfinity/icskills/main/skills/ckbtc/SKILL.md
7475
```
7576

7677
### OpenCode
@@ -126,9 +127,16 @@ curl -sL https://raw.githubusercontent.com/dfinity/icskills/main/skills/ckbtc/SK
126127

127128
The files are plain markdown. Copy the content into whatever instructions, rules, or context file your tool supports.
128129

129-
## API (Planned)
130+
## Programmatic Access
131+
132+
| Resource | URL | Description |
133+
|----------|-----|-------------|
134+
| Skill index | [`llms.txt`](https://dfinity.github.io/icskills/llms.txt) | Short index with links to each skill |
135+
| All skills | [`llms-full.txt`](https://dfinity.github.io/icskills/llms-full.txt) | All skills concatenated for direct context injection |
136+
| Single skill | `https://raw.githubusercontent.com/dfinity/icskills/main/skills/{id}/SKILL.md` | Raw markdown for one skill |
137+
| Agent discovery | [`.well-known/agent.json`](https://dfinity.github.io/icskills/.well-known/agent.json) | Machine-readable skill manifest |
130138

131-
The website documents a REST API for programmatic access:
139+
## REST API (Planned)
132140

133141
| Endpoint | Description |
134142
|----------|-------------|
@@ -150,6 +158,8 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for how to add or update skills.
150158
- **Site**: [Preact](https://preactjs.com/) + [Vite](https://vite.dev/) — 3kb runtime, ~16kb gzipped total
151159
- **Hosting**: GitHub Pages via Actions
152160
- **Skills**: Plain markdown files in `skills/*/SKILL.md`
161+
- **Validation**: Structural linter for frontmatter, sections, and dependency graph (`npm run validate`)
162+
- **Schema**: JSON Schema for frontmatter at `skills/skill.schema.json`
153163

154164
## License
155165

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@
66
"license": "MIT",
77
"type": "module",
88
"scripts": {
9-
"generate": "node scripts/generate-skills.js && node scripts/generate-llms-full.js && node scripts/generate-llms.js && node scripts/generate-agent-json.js && node scripts/generate-sitemap.js",
10-
"dev": "npm run generate && vite",
11-
"build": "npm run generate && vite build && node scripts/generate-skill-pages.js",
9+
"validate": "node scripts/validate-skills.js",
10+
"generate": "node scripts/generate-skills.js && node scripts/generate-llms-full.js && node scripts/generate-llms.js && node scripts/generate-agent-json.js",
11+
"dev": "npm run validate && npm run generate && vite",
12+
"build": "npm run validate && npm run generate && vite build && node scripts/generate-skill-pages.js && node scripts/generate-sitemap.js",
1213
"preview": "vite preview"
1314
},
1415
"dependencies": {

public/.well-known/agent.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@
1919
"wallet"
2020
]
2121
},
22+
"endpoints": {
23+
"list": "https://dfinity.github.io/icskills/llms.txt",
24+
"full": "https://dfinity.github.io/icskills/llms-full.txt",
25+
"skill": "https://raw.githubusercontent.com/dfinity/icskills/main/skills/{id}/SKILL.md"
26+
},
2227
"defaultInputModes": [
2328
"text/plain"
2429
],

public/.well-known/ai-plugin.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
"schema_version": "v1",
33
"name_for_human": "IC Skills",
44
"name_for_model": "ic_skills",
5-
"description_for_human": "Agent-readable skill files for Internet Computer (ICP) development. Covers ckBTC, ICRC ledger, Internet Identity, stable memory, HTTPS outcalls, EVM RPC, SNS, and more.",
6-
"description_for_model": "Retrieve structured skill files for Internet Computer (ICP) development. Each skill is a markdown document with prerequisites, pitfalls, tested code blocks, and deploy commands. Use the raw GitHub URLs to inject skills directly into context. Available skills: ckbtc, icrc-ledger, internet-identity, multi-canister, stable-memory, https-outcalls, evm-rpc, asset-canister, certified-variables, sns-launch, vetkd, wallet.",
5+
"description_for_human": "Agent-readable skill files for Internet Computer (ICP) development. Covers 12 capabilities including ckBTC, ICRC ledger, Internet Identity, stable memory, HTTPS outcalls, EVM RPC, SNS, and more.",
6+
"description_for_model": "Retrieve structured skill files for Internet Computer (ICP) development. Each skill is a markdown document with prerequisites, pitfalls, tested code blocks, and deploy commands. Use the raw GitHub URLs to inject skills directly into context. Available skills: asset-canister, certified-variables, ckbtc, evm-rpc, https-outcalls, icrc-ledger, internet-identity, multi-canister, sns-launch, stable-memory, vetkd, wallet.",
77
"auth": {
88
"type": "none"
99
},

0 commit comments

Comments
 (0)