A coding agent that meets Context-Generic Programming (CGP) in a Rust
project starts with little reliable knowledge of it. CGP's macros generate traits and impls the
agent never sees, and what it learned in training may show syntax the library no longer accepts.
This repository holds the /cgp skill, which teaches an agent to read, write, debug, and explain
CGP code. The agent loads it when a task involves CGP, so you can ask about wiring or a confusing
compile error and get an answer in CGP's own terms.
The skill supports cgp v0.8.0 and every later release, though not an older cgp. Because it
keeps improving between releases, you install it from this repository's main branch and update it
from there. It is plain Markdown, with no scripts, and it summarizes the
CGP knowledge base, which it links for
detail.
Website · Installation · Quickstart · Reference
The quickest route is to give your agent this repository's URL,
https://github.com/contextgeneric/cgp-skills, and ask it to install the /cgp skill. The steps
below are written for it as much as for you. The website's
installation page covers each harness in
more detail.
If you are an agent installing this skill, follow these steps:
- Ask the user whether to install the skill for them in every project, or only in the current project, where it can be committed for the whole team.
- Use the harness's own installer when it has one, from the list below.
- Otherwise copy the
cgp/directory from themainbranch into the harness's skills directory from the table further down. Copy it rather than linking a clone, and keepSKILL.mdandreferences/together. - Install through one route only, because a plugin and a copy together give the harness two copies of the skill.
- Check that the harness now lists a skill named
cgp, which may need a new session. - Change no other setting without asking.
These harnesses and tools have their own installers, and each one takes the skill from main:
- Claude Code: run
/plugin marketplace add contextgeneric/cgp-skills, then/plugin install cgp@cgp-skills. The plugin's skill is/cgp:cgp. - Codex: run
codex plugin marketplace add contextgeneric/cgp-skills, thencodex plugin add cgp@cgp-skills. Codex lists the skill ascgp:cgp. Its built-in$skill-installercan also installhttps://github.com/contextgeneric/cgp-skills/tree/main/cgpwhen asked. - Gemini CLI: run
gemini skills install https://github.com/contextgeneric/cgp-skills.git --path cgp, which takes the default branch,main. - Pi: run
pi install git:github.com/contextgeneric/cgp-skills, adding-lto install it for the current project. - Any agent the installers support: run
npx skills add contextgeneric/cgp-skills --skill cgp, adding-gto install it for every project. It sends anonymous telemetry unlessDISABLE_TELEMETRY=1is set. The GitHub CLI does the same withgh skill install contextgeneric/cgp-skills cgp, choosing the harness with--agentand the scope with--scope.
To copy the skill by hand, clone the repository and copy cgp/ into the directory this table gives
for your harness:
| Harness | For you, in every project | For one project |
|---|---|---|
| Claude Code | ~/.claude/skills/cgp |
.claude/skills/cgp |
| Codex | ~/.agents/skills/cgp |
.agents/skills/cgp |
| Cursor | ~/.cursor/skills/cgp |
.cursor/skills/cgp |
| GitHub Copilot and VS Code | ~/.copilot/skills/cgp |
.github/skills/cgp |
| Gemini CLI | ~/.gemini/skills/cgp |
.gemini/skills/cgp |
| OpenCode | ~/.config/opencode/skills/cgp |
.opencode/skills/cgp |
| Pi and most other agents | ~/.agents/skills/cgp |
.agents/skills/cgp |
For Claude Code, installing for yourself, the commands are:
git clone --depth 1 https://github.com/contextgeneric/cgp-skills.git
mkdir -p ~/.claude/skills
cp -R cgp-skills/cgp ~/.claude/skills/cgpA copied skill is /cgp in Claude Code.
Fixes and better explanations reach main between cgp releases, so update the skill from time to
time, and whenever your project moves to a newer cgp. The skill helps with the second case: when
the project's cgp is newer than the releases it describes, it has the agent check main and tell
you when a newer skill is there. Each route updates with its own command:
- Claude Code: run
claude plugin marketplace update cgp-skills, thenclaude plugin update cgp@cgp-skills, and start a new session. To have it update by itself, open/plugin, selectcgp-skillsin the Marketplaces tab, and choose Enable auto-update, which is off for marketplaces outside Anthropic's own. - Codex: run
codex plugin marketplace upgrade cgp-skills, thencodex plugin add cgp@cgp-skills. - Gemini CLI: it has no update command, so run
gemini skills uninstall cgp, then install the skill again. - Pi: run
pi update --extensions. A plainpi updateupdates only Pi itself. npx skillsand the GitHub CLI: runnpx skills update cgp, adding-gfor an install in every project, orgh skill update cgp.- A copy: remove the old directory and copy
cgp/again from a fresh clone, sincecp -Rputs a new copy inside an existing directory.
cgp is the foundational skill for CGP in Rust. Its SKILL.md explains consumer
and provider traits, wiring, and impl-side dependencies, and recommends cargo-cgp for readable
errors. From there it sends the agent to the reference that owns the task at hand:
- Core constructs: components, wiring, checking, functions and getters, abstract types, and higher-order providers.
- Supporting constructs: error handling, the error backends, handlers, extensible data, namespaces, and type-level primitives.
- Syntax and diagnosis: modern idioms, macro grammar, and error extraction.
- Design choices: the modularity hierarchy, for deciding how much CGP a problem needs.
- Versions: versions, for matching the skill to the project's
cgpand telling the user when the project or the skill needs an update.
A skill has to fit in an agent's context window, so it gathers the core concepts, the common constructs, and worked examples from across the knowledge base, and links the online reference for what it leaves out. The knowledge base, by contrast, gives the exhaustive account: every construct, the internals, the examples, and the comparisons with other approaches. Where the code and either document disagree, the CGP source is the authority.
The skill teaches an agent rather than a person. If you are learning CGP yourself, start at the website with the quickstart and the tutorials. Either way, review what an agent writes with the skill as you would any other change.
CI runs python3 scripts/check.py, which checks that each file has exactly one # heading, that
the relative links inside cgp/ resolve, and that the skill's frontmatter meets the
Agent Skills specification: its name matches its
directory, its description stays within 1024 characters, and it sets a license. It also checks
that the plugin manifests and package.json parse as JSON and agree with the skill: skills paths
that hold a SKILL.md, descriptions that match the skill's first sentence, and no version in
plugin.json or package.json, so a plugin install takes every commit on main as an update.
Finally, it checks that the versions SKILL.md states match the table in
versions.
sibling-projects.md lists the related repositories, and contributors follow AGENTS.md, which keeps the skill in step with the code and the knowledge base.
Licensed under the Apache License, Version 2.0.