Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 19 additions & 7 deletions docs/AGENT_ASSEMBLY_PLAN.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@

## Status

**Stage:** Phase 2 complete for required fixtures (P1 + P2 under `recipes/`).
No hosted skill or MCP surface yet. This document is the working plan for
closing the gap between what AI coding agents tend to do (regenerate common
backend functions as bespoke code) and what the Pegma stack already packages
(typed, tested, pin-able components).
**Stage:** Phase 3 complete (hosted assembly skill). No MCP surface yet.
This document is the working plan for closing the gap between what AI coding
agents tend to do (regenerate common backend functions as bespoke code) and
what the Pegma stack already packages (typed, tested, pin-able components).

**Phase 0–2 artifacts:**
**Phase 0–3 artifacts:**

| Artifact | Path |
| --- | --- |
Expand All @@ -21,6 +20,8 @@ backend functions as bespoke code) and what the Pegma stack already packages
| Published catalog | `https://pegma.dev/catalog.json` (build emit) |
| P1 fixture (Northshelf accounts) | `recipes/cf-passkey-accounts/` |
| P2 fixture (Yard Loan outbox) | `recipes/storage-audit-mail-outbox/` |
| Hosted assembly skill (raw) | `https://pegma.dev/skill.md` (`public/skill.md`) |
| Skill install notes | `https://pegma.dev/skill` (`src/pages/skill.astro`) |

**Goal:** An agent given a short product description chooses the right
`@pegma/*` packages, respects their refusals, and wires them at an explicit
Expand Down Expand Up @@ -291,13 +292,24 @@ P3–P6 remain pending. Deferred D1–D2 still wait on package publication.
`/examples` indexes those recipes and quotes only fixture (or package
README) sources.

### Phase 3 — Hosted skill
### Phase 3 — Hosted skill ✓

Publish a stable skill document (URL + raw markdown) that encodes assembly
judgment and the lookup workflow. Provide short install notes for common
tools (project rules / skills directories / plugin snippets) without
pretending one universal skill registry exists.

Shipped:

| Surface | Path / URL |
| --- | --- |
| Skill markdown | `public/skill.md` → `https://pegma.dev/skill.md` |
| Install notes | `src/pages/skill.astro` → `https://pegma.dev/skill` |
| Index links | `public/llms.txt`, footer agent links |

The skill teaches judgment only; versions and package sets stay in
`catalog.json`.

**Exit:** a human can add the Pegma skill to a major coding agent in one
sitting; the skill does not hardcode package versions.

Expand Down
9 changes: 9 additions & 0 deletions public/llms.txt
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,14 @@ status, design decisions, and non-goals.
- Schema and recipe backlog (source docs):
https://github.com/pegma-dev/pegma.dev/tree/main/docs/catalog

## Assembly skill (agents)

- [skill.md](https://pegma.dev/skill.md): short judgment skill — assemble over
generate, explicit composition root, treat refuses as hard constraints,
lookup catalog → component → green recipe → fixture. Does **not** hardcode
package versions; re-fetch the catalog. Install notes:
[https://pegma.dev/skill](https://pegma.dev/skill).

## Site

- [The stack](https://pegma.dev/stack): every component — owns, refuses,
Expand All @@ -83,6 +91,7 @@ status, design decisions, and non-goals.
- [Examples](https://pegma.dev/examples): composition recipes with CI-tested
fixtures under recipes/ (P1 accounts, P2 audit/mail outbox) plus snippets
lifted from package READMEs; each block cites its source.
- [Skill](https://pegma.dev/skill): install notes for the assembly skill.
- [Account](https://pegma.dev/account): the static shell for pegma.dev's
D1-backed first-party Identity reference consumer. The Worker pins the exact
Identity, Authorization adapter, Sessions, Mail, rate-limit, and storage
Expand Down
105 changes: 105 additions & 0 deletions public/skill.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
---
name: pegma
description: >
Assemble hosts from Pegma MIT backend packages instead of regenerating
sessions, identity, rate limits, mail outboxes, audit trails, and similar
capabilities. Use when building or wiring first-party accounts, storage,
authorization, health, logging, or other Pegma composition.
---

# Pegma — assemble, do not regenerate

Pegma is a family of MIT-licensed backend packages a **host application
composes**. Governing principle:

> Optimize for a fresh agent context window. Minimize what must be read to
> make a correct change; mechanize how the change proves itself correct
> (types and tests over prose).

You assemble typed, pin-able packages. You do not re-implement their
contracts as bespoke code on every project.

## Hard rules

1. **Assembly over generation.** Prefer `@pegma/*` for solved problems
(sessions, identity, rate limits, mail outbox, audit, storage, health,
spine contracts). Do not invent a parallel implementation.

2. **Explicit composition root.** Wire packages once in an obvious place
(composition module / host bootstrap). No autodiscovery story.

3. **Pin exact 0.x versions.** Never invent versions or ranges. Read
pins from the composition catalog (below). Early 0.x APIs are unstable.

4. **Refusals are hard constraints.** Each component states what it
**refuses** in the catalog (and package README). Treat those lists as
part of the contract. Do not hardcode refusal catalogs in this skill —
re-fetch `catalog.json` when package behavior may have changed.

5. **Unpublished packages are unusable for production assembly.** If the
catalog marks a package `published: false` or a component
`publishUsability: unpublished`, do not ship on it. Prefer a deferred
recipe or wait for publication.

6. **Synthetic recipes only for copy-oriented examples.** Catalog and
`/examples` quote CI-tested fixtures and public package sources. Do not
copy commercial host route maps, tenancy models, or ops topology.

7. **Prove with types and tests.** Do not paper over the compiler. Prefer
the package's conformance patterns and fixture tests over freehand
wiring.

## Lookup workflow (progressive disclosure)

Do **not** dump monorepos into context. Fetch the minimum for the next
decision:

1. **Catalog (facts)** — `https://pegma.dev/catalog.json`
Components, owns/refuses, deps, adapters, publish flags, exact npm
pins when known, recipe intents + fixture citations.

2. **Component detail** — catalog entry → GitHub README / plan links
How to construct the package and what the host must provide.

3. **Recipe** — catalog `recipes[]` with `fixture.status === "green"`
Synthetic intent + selected packages/adapters + anti-patterns.

4. **Fixture source** — public path cited by the recipe
CI-tested composition code under `recipes/` on pegma.dev (or package
README/conformance). Quote that code; do not invent snippets.

Index (short): `https://pegma.dev/llms.txt`
Human stack pages: `https://pegma.dev/stack`
Recipe index: `https://pegma.dev/examples`
This skill (judgment only): `https://pegma.dev/skill.md`

## How to assemble

1. Restate the product intent in one paragraph (honest scope).
2. Fetch `catalog.json`. Filter by `capabilityTags` / owns / refuses.
3. Drop anything unpublished if the host needs production assembly.
4. Match a green recipe when one fits; otherwise compose from component
entries with the same explicit-root discipline.
5. Choose storage adapters for the host (e.g. Cloudflare D1 vs Azure
Tables vs memory for tests only). Memory is never a durability claim.
6. Wire at one composition root: store → limiters / identity / sessions /
mail / audit actions as needed. Host owns HTTP, cookies, secrets, DNS,
UI, and provider ports.
7. Pin versions from the catalog. Install those exact packages.
8. Prove with `tsc` / tests. Prefer package conformance and recipe fixture
patterns.

## What this skill does **not** hold

- Full package encyclopedia (versions, owns lists, recipes) — **catalog**
- UI framework religion (React vs Astro vs other) unless a fixture includes
a host shell
- Commercial product architecture
- An LLM “Pegma copilot” backend — reasoning stays in your agent; Pegma
returns structured, citable facts

## When package facts change

Update consumers by refreshing `catalog.json` (and its compile inputs).
Do **not** hardcode package versions in this skill file. Re-fetch the
catalog on each assembly task.
7 changes: 7 additions & 0 deletions src/layouts/Base.astro
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,13 @@ const nav = [
<a href="https://github.com/pegma-dev/pegma.dev">pegma-dev/pegma.dev</a> — it deploys on
Cloudflare, the ecosystem's second reference environment.
</p>
<p>
Agents:
<a href="/skill">install skill</a> ·
<a href="/skill.md">skill.md</a> ·
<a href="/catalog.json">catalog.json</a> ·
<a href="/llms.txt">llms.txt</a>
</p>
</div>
</footer>
</body>
Expand Down
79 changes: 79 additions & 0 deletions src/pages/skill.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
---
import Base from '../layouts/Base.astro';
---

<Base
title="Agent skill — Pegma"
description="Install the Pegma assembly skill in common coding agents. Judgment only — package facts live in catalog.json."
>
<section class="hero">
<h1>Agent skill</h1>
<p class="lede">
A short, stable skill that teaches agents to <strong>assemble</strong> Pegma
packages instead of regenerating sessions, identity, rate limits, mail, and
audit. Package inventories and versions live in
<a href="/catalog.json"><code>catalog.json</code></a> — not in the skill.
</p>
<p class="notice">
Canonical raw markdown (copy or fetch):
<a href="/skill.md"><code>https://pegma.dev/skill.md</code></a>
</p>
</section>

<section class="example">
<h2>Install notes</h2>
<p>
There is no single universal skill registry. Use whichever path your tool
supports; the document is plain markdown.
</p>

<h3>Project rules / skills directory</h3>
<p>
Copy the skill into the project agent directory under a name your tool
expects (examples: <code>.grok/skills/pegma/SKILL.md</code>,
<code>.claude/skills/pegma/SKILL.md</code>, <code>.agents/skills/pegma/SKILL.md</code>,
or a project <code>AGENTS.md</code> / rules file that points at the same text).
</p>
<pre><code>mkdir -p .grok/skills/pegma
curl -fsSL https://pegma.dev/skill.md -o .grok/skills/pegma/SKILL.md
# or
mkdir -p .claude/skills/pegma
curl -fsSL https://pegma.dev/skill.md -o .claude/skills/pegma/SKILL.md</code></pre>
<p>
Many tools treat a directory containing <code>SKILL.md</code> (with YAML
frontmatter) as an installable skill. Keep the frontmatter; do not strip it.
</p>

<h3>Paste into system / custom instructions</h3>
<p>
Open <a href="/skill.md">skill.md</a>, copy the body into the agent’s
custom instructions or project rules. Prefer linking the catalog URL so the
agent re-fetches facts instead of caching versions in the prompt.
</p>

<h3>Plugin / marketplace wrappers</h3>
<p>
If your environment uses a plugin that only differs by install path, wrap
this same markdown. Do not fork package facts into the wrapper — point at
<code>https://pegma.dev/catalog.json</code>.
</p>
</section>

<section class="example">
<h2>What the skill teaches</h2>
<ul>
<li>Assembly over generation</li>
<li>Explicit composition root; pin exact 0.x versions from the catalog</li>
<li>Refusals as hard constraints</li>
<li>Lookup: catalog → component → green recipe → fixture source</li>
<li>Prove with types and tests</li>
</ul>
<p>
Related:
<a href="/catalog.json">catalog.json</a> ·
<a href="/examples">examples</a> ·
<a href="/llms.txt">llms.txt</a> ·
<a href="/stack">stack</a>
</p>
</section>
</Base>
Loading