Agent skill

New Pattern Authoring Workflow

by Totoro-jam in Totoro-jam/battle-tested-patterns

Step-by-step workflow for adding a new pattern to the battle-tested-patterns repo: validate the topic, verify sources, write the doc, code and exercises.

MITAuto-check passedDevelopment

Install New Pattern Authoring Workflow

skills CLI
$ npx skills add Totoro-jam/battle-tested-patterns --skill new-pattern -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install Totoro-jam/battle-tested-patterns new-pattern --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/Totoro-jam/battle-tested-patterns.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.claude/skills/new-pattern .claude/skills/new-pattern && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
new-pattern
GitHub stars
344
Token cost
~1.5k tokens
SKILL.md length
641 words
Files
1
Skills in repo
5
Repo updated
First seen
Licence
MIT

At a glance

Step-by-step workflow for adding a new pattern to the battle-tested-patterns repo: validate the topic, verify sources, write the doc, code and exercises.

  • Works in 11 steps: Topic Validation → Source Code Location → Write the Document → …
  • Contributing a new programming pattern to the battle-tested-patterns repository
  • SKILL.md covers Step 1: Topic Validation, Step 2: Source Code Location, Step 3: Write the Document and Step 4: Implement, plus 7 more sections
  • Calls pnpm, git and curl; reaches github.com

What it does

The skill guides the agent through every step of contributing one pattern to the battle-tested-patterns project, and forbids skipping source verification. It starts by asking five questions: the pattern name, at least 2 production projects that use it with source links, whether it works across languages, whether it is a code-level technique rather than purely architectural, and whether docs/patterns/ already holds a duplicate. Any no answer stops the work with an explanation.

Sources come next. For each production project the agent finds the exact usage, builds a GitHub URL with line numbers, checks that it returns HTTP 200 with curl, and writes a Production Proof specific enough to learn from without clicking. A link that cannot be verified is never invented. The document goes in docs/patterns/ under the pattern name as index.md, opening with a one-liner of at most 30 English words and a core idea with a diagram suited to the pattern.

Implementation requires an idiomatic TypeScript version plus at least one of Rust, Go or Python, checked with `pnpm verify-code`. Exercises are created under exercises/typescript, and the docs are bilingual, with notes on keeping ASCII diagrams aligned in the Chinese version. The excerpt is cut off after the exercises step.

When your agent uses it

  • Contributing a new programming pattern to the battle-tested-patterns repository
  • Checking that a proposed pattern has real production sources before writing it up
  • Writing a pattern doc with TypeScript and a second language implementation

Example prompts

  • “Create a new pattern for the circuit breaker following the project workflow.”
  • “Validate whether write-ahead logging qualifies as a new pattern before we draft anything.”
  • “Add the ring buffer pattern with TypeScript and Rust examples and exercises.”

Requirements

  • A checkout of the battle-tested-patterns repository
  • pnpm for the verify-code script
  • curl for checking source links

Workflow steps

11 steps, taken from the step headings in SKILL.md.

  1. Topic Validation
  2. Source Code Location
  3. Write the Document
  4. Implement
  5. Design Exercises
  6. Write Challenge Questions
  7. Create Chinese Translation
  8. Update Navigation
  9. Full Verification
  10. Site Accessibility Verification
  11. Commit and Tag

What it can do on your machine

Read from SKILL.md and the folder at commit 660e0e9. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • pnpm
    • git
    • curl

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    Hosts in commands or code, which the agent is likely to contact:

    • github.com

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

New Pattern Authoring Workflow loads about 1.5k tokens when it runs. Until then it costs about 57 tokens; SKILL.md has 641 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~57
When it runs · the whole SKILL.md, loaded when a task matches
~1.5k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from Totoro-jam/battle-tested-patterns at commit 660e0e9, republished under its MIT licence (© Totoro-jam). 641 words, ~1,520 tokens.

Download SKILL.mdSave it as .claude/skills/new-pattern/SKILL.md (or your agent's skills folder).
name
new-pattern
description
Guided workflow to create a new pattern following the project template and quality standards. Walks through topic validation, source verification, implementation, exercises, challenge questions, and bilingual docs.

Create a New Pattern

You are creating a new pattern for battle-tested-patterns. Follow each step in order. Do NOT skip source verification. Reference SOP 01 for the full checklist.

Step 1: Topic Validation

Ask these questions before proceeding:

  1. What is the pattern name?
  2. Can you name ≥ 2 production projects that use it (with source links)?
  3. Is it cross-language (not specific to one language/framework)?
  4. Is it a code-level technique (not purely architectural)?
  5. Does it NOT duplicate an existing pattern in docs/patterns/?

If any answer is "no", stop and explain why this pattern doesn't fit.

Step 2: Source Code Location

For each production project:

  1. Search the project repo for the exact usage
  2. Get the GitHub URL with line numbers: https://github.com/{org}/{repo}/blob/main/{path}#L{start}-L{end}
  3. Verify with curl -sI <url> | head -1 — must return HTTP 200
  4. Read the code to confirm your understanding
  5. Write a Production Proof description specific enough to learn WITHOUT clicking the link

CRITICAL: Never fabricate a URL. If you cannot verify a link, write <!-- TODO: verify source link --> instead.

Step 3: Write the Document

Create docs/patterns/<pattern-name>/index.md with ALL required sections:

# Pattern: [Name]
## One Liner          ← ≤ 30 English words, capture WHY not just WHAT
## Core Idea          ← concept + diagram (choose best representation for this pattern)
## Production Proof   ← table with ≥ 2 verified URLs, descriptions show HOW not just WHAT
## Implementation     ← TypeScript (required) + ≥ 1 other language in ::: code-group
## Exercises          ← table with basic + intermediate exercise links
## When to Use        ← ≥ 3 concrete scenarios
## When NOT to Use    ← ≥ 2 concrete alternatives
## More Production Uses ← bullet list with repo links
## Challenge Questions ← 3-4 scenario Q&A using ::: details syntax
Diagram Guidelines
  • Choose the representation that best matches the pattern's nature:
    • Ring/circular → for hash rings, ring buffers
    • Timeline → for temporal patterns (WAL, MVCC, retry)
    • State diagram → for state machines, circuit breakers (use mermaid)
    • Tree → for tries, heaps, B-trees
    • Box-and-arrow → for data structures (LRU, skip list)
  • ASCII text blocks: every box border must be vertically aligned
  • ZH docs: CJK characters = 2 display columns; compensate with fewer spaces
  • Verify alignment in a monospace font before committing

Step 4: Implement

In the ::: code-group block:

  • TypeScript (required) — idiomatic, strict types, no any
  • At least one of: Rust / Go / Python
  • Each implementation must be idiomatic, not a line-by-line translation
  • Go: do NOT add import blocks — the verify-code script auto-detects imports
  • Rust: wrap standalone code in fn main() or use pub struct/pub fn
  • Verify: pnpm verify-code

Step 5: Design Exercises

Create in exercises/typescript/<pattern>/:

  • 01-basic.test.ts — basic pattern mechanics (required)
  • 02-intermediate.test.ts — real-world application scenario (required)
  • Use TODO-stub format with // TODO: implement markers
  • Include working implementations so CI passes
  • Separator: // ─── Tests (do not modify below this line) ───────────────────────
  • 4-5 meaningful test cases per exercise
  • Verify: pnpm test:exercises AND pnpm typecheck
Show full SKILL.md (278 more words)Show less

Step 6: Write Challenge Questions

Add ## Challenge Questions at the end of the EN doc:

  • 3-4 questions using ::: details Q1: [question] ... ::: syntax
  • Questions test understanding through production scenarios
  • Verify factual accuracy of all answers
  • Escape | in table cells, use × instead of * for multiplication
  • Copy to ZH doc with header ## 挑战题, translate Q&A to Chinese (keep technical terms and code in English)

Step 7: Create Chinese Translation

Create docs/zh/patterns/<pattern-name>/index.md:

  • Translate structural content (headings, explanations, When to Use)
  • Keep code blocks identical to English
  • Keep Production Proof links identical
  • Challenge Questions: translate questions + answers to Chinese, keep technical terms/code in English
  • ASCII diagrams: use English labels inside box-drawing diagrams (no CJK in diagrams)

Step 8: Update Navigation

All of these must be updated:

  • docs/.vitepress/config.ts — BOTH English and Chinese sidebar
  • docs/index.md — English homepage pattern table
  • docs/zh/index.md — Chinese homepage pattern table
  • README.md — pattern table + cheat sheet table
  • README.zh-CN.md — pattern table + cheat sheet table
  • docs/by-project/*.md — add to ALL relevant project pages (React, Linux, Go, Redis, etc.)
  • docs/by-project/more-projects.md — add if project not covered by specific pages
  • docs/zh/by-project/*.md — sync Chinese versions
  • README.md cheat sheet — add to correct category table
  • README.zh-CN.md cheat sheet — sync Chinese version
  • docs/guide/pattern-connections.md + ZH — update if pattern fits a system case study

Step 9: Full Verification

Run ALL checks before committing:

bash
pnpm check         # All checks (lint + typecheck + test + verify-code + verify-mermaid + check:content)
pnpm build         # VitePress builds

Step 10: Site Accessibility Verification

After build, verify all new pages are reachable:

  • ls docs/.vitepress/dist/patterns/<name>/index.html — EN page exists
  • ls docs/.vitepress/dist/zh/patterns/<name>/index.html — ZH page exists
  • After deploy, spot-check live URLs in both languages

Step 11: Commit and Tag

  • Commit message: feat: add <pattern-name> pattern
  • If adding multiple patterns: one commit per batch with list
  • Push and verify CI is green before tagging
  • Tag: git tag -a v1.X.0 -m "description" + git push origin v1.X.0

© Totoro-jam, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in .claude/skills/new-pattern of Totoro-jam/battle-tested-patterns.

Open the folder on GitHubat commit 660e0e9

Compare with similar skills

New Pattern Authoring Workflow next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

New Pattern Authoring Workflow compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
New Pattern Authoring Workflow this skillTotoro-jam/battle-tested-patterns344—~1.5kAutomated safety check: PassMIT
Generating Documentationancoleman/ai-design-components526—~3kAutomated safety check: PassMIT
Design Patternswaybarrios/opencode-power-pack533—~2.2kAutomated safety check: PassMIT
Writing Code CommentsPostHog/posthog40k—~1.6kAutomated safety check: PassCustom licence
Pnpm Engineteambit/bit18k—~1.9kAutomated safety check: PassCustom licence
Testing Changespnpm/pnpm37k—~1.1kAutomated safety check: PassMIT

Similar skills

  • Generating Documentation

    ancoleman/ai-design-components

    Generate comprehensive technical documentation including API docs (OpenAPI/Swagger), code documentation (TypeDoc/Sphinx), documentation sites (Docusaurus/MkDocs), Architecture Decision Records…

    526 GitHub stars~3k tokensUpdated 10 mo ago
    DevelopmentAuto-check passed
  • Design Patterns

    waybarrios/opencode-power-pack

    Agents should invoke this skill when choosing patterns, designing traits/interfaces/components, deciding abstraction boundaries, evaluating dependency injection/callbacks, or comparing…

    533 GitHub stars~2.2k tokensUpdated 2 days ago
    DevelopmentAuto-check passed
  • Writing Code Comments

    PostHog/posthog

    Official

    Gates whether a code comment should exist and forces the ones that stay to explain why, not what.

    40k GitHub stars~1.6k tokensUpdated today
    DevelopmentAuto-check passed
  • Pnpm Engine

    teambit/bit

    Work on the pnpm Rust engine (@pnpm/napi, the pacquet crates) that bit install runs through.

    18k GitHub stars~1.9k tokensUpdated today
    DevelopmentAuto-check passed
  • Run the tests that cover a change in the pnpm repository, in the Rust workspace (pnpm/, pnpr/) or the TypeScript CLI (pnpm11/), and recognize the cases where a scoped run passes without testing…

    37k GitHub stars~1.1k tokensUpdated today
    DevelopmentAuto-check passed
  • Measures a code port between languages or frameworks with jscpd's function-level comparison, porting tests before code and tracking what is left unmatched.

    6.4k GitHub stars~5k tokensUpdated today
    DevelopmentAuto-check passed

More from Totoro-jam/battle-tested-patterns

  • Adopt a Design Pattern

    Totoro-jam/battle-tested-patterns

    Matches a coding problem to one of 46 documented systems patterns, checks that it really fits, then adapts it into your codebase with a test for its invariant.

    344 GitHub stars~4.9k tokensUpdated 1 mo ago
    Auto-check passed
  • Pattern Conformance Audit

    Totoro-jam/battle-tested-patterns

    Audits a codebase's existing patterns, such as rate limiters, circuit breakers and caches, against canonical invariants and flags mislabeled or divergent ones.

    344 GitHub stars~1.6k tokensUpdated 1 mo ago
    Auto-check passed
  • Verify Source

    Totoro-jam/battle-tested-patterns

    Verify all production proof source links in pattern documents.

    344 GitHub stars~930 tokensUpdated 1 mo ago
    Auto-check passed
  • Failure Diagnosis Loop

    Totoro-jam/battle-tested-patterns

    Walks the agent through a fixed loop for failing tests and build errors: reproduce, isolate, hypothesize, instrument, fix, verify, then add a regression test.

    344 GitHub stars~319 tokensUpdated 1 mo ago
    Auto-check passed

Questions about New Pattern Authoring Workflow

What does New Pattern Authoring Workflow do?

Step-by-step workflow for adding a new pattern to the battle-tested-patterns repo: validate the topic, verify sources, write the doc, code and exercises. The skill guides the agent through every step of contributing one pattern to the battle-tested-patterns project, and forbids skipping source verification. It starts by asking five questions: the pattern name, at least 2 production projects that use it with source links, whether it works across languages, whether it is a code-level technique rather than purely architectural, and whether docs/patterns/ already holds a duplicate.

When should I use New Pattern Authoring Workflow?

New Pattern Authoring Workflow fits situations like: contributing a new programming pattern to the battle-tested-patterns repository; checking that a proposed pattern has real production sources before writing it up; writing a pattern doc with TypeScript and a second language implementation.

How do I install New Pattern Authoring Workflow in Claude Code?

Run `npx skills add Totoro-jam/battle-tested-patterns --skill new-pattern -a claude-code`. Or copy the skill folder (.claude/skills/new-pattern in Totoro-jam/battle-tested-patterns) into .claude/skills/new-pattern in your project. Claude Code loads it when a task matches its description.

How do I install New Pattern Authoring Workflow in Codex?

Run `npx skills add Totoro-jam/battle-tested-patterns --skill new-pattern -a codex`. Or copy the skill folder (.claude/skills/new-pattern in Totoro-jam/battle-tested-patterns) into .agents/skills/new-pattern in your project. Codex loads it when a task matches its description.

Can I use New Pattern Authoring Workflow in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add Totoro-jam/battle-tested-patterns --skill new-pattern -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/new-pattern, .gemini/skills/new-pattern, .github/skills/new-pattern and .opencode/skills/new-pattern in your project.

What does New Pattern Authoring Workflow need to run?

Going by SKILL.md and its folder, New Pattern Authoring Workflow needs the command-line tools its instructions call (pnpm, git and curl). Our summary lists: A checkout of the battle-tested-patterns repository; pnpm for the verify-code script; curl for checking source links.

Does New Pattern Authoring Workflow access the network?

SKILL.md names 1 domain. In commands or code: github.com; the agent is likely to contact it when it follows the instructions. This is read from the text; nothing was executed.

Is New Pattern Authoring Workflow safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does New Pattern Authoring Workflow use?

New Pattern Authoring Workflow is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does New Pattern Authoring Workflow use?

About 1.5k tokens (SKILL.md is roughly 6.1k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to New Pattern Authoring Workflow?

Skills that share tags, products or a category with New Pattern Authoring Workflow: Generating Documentation (ancoleman/ai-design-components, 526 stars), Design Patterns (waybarrios/opencode-power-pack, 533 stars), Writing Code Comments (PostHog/posthog, 40k stars) and Pnpm Engine (teambit/bit, 18k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains New Pattern Authoring Workflow?

Totoro-jam (a GitHub user) maintains it in Totoro-jam/battle-tested-patterns, which has 344 GitHub stars. The repository holds 5 skills in this directory. The repository was last updated on September 4, 2026.

Source: Totoro-jam/battle-tested-patterns on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.