Patterns

Importing a pattern

How the reference token brings a pattern into your workspace, how paths are chosen, and how to remove a bundle later.


You can adopt any pattern in two ways. You can copy the bundle by hand from the catalog, or you can import it with a single token and let Pathrule write the pieces onto the right paths for you.

The reference token

Every pattern has a reference token of the form:

::pathrule:package:<slug>

For example, the Next.js App Router pattern is ::pathrule:package:nextjs-app-router. The token is shown on each catalog page, ready to copy.

The ::pathrule: prefix is a reserved namespace. It is matched before the ::skill-name invocation path, so a pattern token is never mistaken for a skill and never triggers skill discovery. That separation holds across every client, including the offline prompt hook.

Importing by token

To add a pattern, paste its token into your AI assistant in a connected workspace. From there Pathrule does the rest:

  1. It recognises the token. When Pathrule builds the context for your prompt, it detects the ::pathrule:package:<slug> marker and surfaces an import directive for that slug.
  2. It previews before writing. A dry-run resolves the pattern and returns its pieces and the paths it intends to use, without changing anything yet. This preview also reports the pattern's declared stack, so the assistant can line the pattern up against your actual project.
  3. It picks paths that match your tree. A pattern declares suggested paths, but real repositories differ. The assistant chooses a base that matches your layout and re-roots the pattern's paths under it, so the pieces land where they actually belong.
  4. It confirms on a mismatch. If the pattern targets a stack your project does not appear to use, for example a React Native pattern in a project with no Expo, the assistant asks you to confirm before writing rather than importing blindly.
  5. It writes the bundle. On confirmation, each piece is created through the normal write path: a memory becomes a memory, a rule becomes a rule with its scope, priority and enforcement, and a skill becomes an invocable skill. Missing nodes along each path are created on demand.

After import, the pieces are ordinary workspace content. They surface through the same hooks and retrieval as anything you wrote yourself, and you edit them the same way.

Importing by manual copy

You do not need the token to use a pattern. Each catalog page has a manual copy action that copies the full bundle as plain markdown, with every piece labelled by kind and target path. Paste that into your assistant, or into your own notes, and recreate the pieces wherever you want. This path works today with no setup.

Every pattern is also available as raw markdown at /patterns/<slug>/raw, which is convenient when you want an assistant to read the whole bundle from a link.

Seed, not subscribe

Importing a pattern is a one-time seed. The copy in your workspace is yours from that moment on; it does not stay linked to the catalog and it will not change underneath you. When a pattern publishes a newer version, that surfaces as an explicit "new version available" prompt so you can review the difference and decide, never as a silent sync over content you may have already adapted.

Re-importing and removing

  • Re-import is idempotent. Running the same import again skips pieces that already exist and reports what was added, so you never end up with duplicates.
  • Removal is one step. Because a pattern's definition is its own manifest of titles and paths, a single remove call can undo the whole bundle at once. Imported pieces are tagged with their source pattern, so removal targets exactly what the import created and leaves your own content untouched.

Where it works

Import behaves the same everywhere Pathrule connects an assistant: Claude Code, Cursor, Codex, Windsurf and GitHub Copilot, on the local runtimes and through the hosted Remote MCP. Clients that cannot inject prompt context rely on the context request and the protocol guidance to learn the same import and remove workflow.