create-tutorial
Skill658 starsChanged 3 months agoApache-2.0View on GitHub
Scaffold a new Membrane API Gateway tutorial in the api-gateway repo — the numbered self-teaching YAML under distribution/tutorials/<category>/, its support files and README links, and the matching auto-discovered integration test. Use whenever the user asks to create, add, write, or scaffold a tutorial (or a tutorial step), even if they only describe the gateway behavior they want to teach and don't say the word "skill" or name the files.
In this repository10 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- config-error-handlingSkill
- find-exampleSkill
- find-interceptor-implSkill
- membrane-configSkill
- optimize-interceptor-docsSkill
- refactorSkill
- release-notesSkill
- review-branchSkill
- run-example-testSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
14 rules. About 0 are common, 5 are distinctive, and 9 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈5
Distinctive · estimate
This author's own choices. Worth a look.
9
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 79
The reader must reach the config without scrolling: If something concrete only shows up after two pages of comments, the reader leaves.
- Very specific: line 83
Don't explain what the config does.
- Distinctive: line 91
Put prompts and notes on their own line:
- Distinctive: line 108
Never comment what the interceptor name already says.
- Very specific: line 117
Use return: status: 200 not return: {}.
- Very specific: line 129
If membrane.sh / membrane.cmd are missing from the category dir, copy them verbatim from a sibling category — they are identical generic …
- Very specific: line 142
Test package mirrors the category but with underscores: dir getting-started → package com.predic8.membrane.tutorials.getting_started.
- Very specific: line 187
If you created a brand-new category, also create its Abstract<Category>TutorialTest modeled on an existing one — it just returns the …
- Very specific: line 197
Run the test through the existing run-example-test skill.
- Very specific: line 210
When a template interceptor has contentType: application/json, the engine automatically adds quotes around every ${...} interpolation.
- Distinctive: line 227
Prefer the built-ins over raw property access:
- Very specific: line 232
Avoid the verbose ${property.'membrane.security.schemes'[0].username} — use ${user()} instead.
- Very specific: line 238
Add a section linking the new category in distribution/tutorials/README.md.
- Distinctive: line 241
Add concrete tests as in Step 4.
≈ “Common” is an estimate: at least 1 in 5 of the 364,980 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Create a Tutorial
In this repo a tutorial is usually a runnable, self-teaching YAML config. The leading comment block of the file is the lesson; the config below it is the working example the reader runs. A complete tutorial therefore has three parts, and they must stay in sync:
- The numbered YAML in
distribution/tutorials/<category>/— the lesson plus the config. - Category support files —
membrane.sh,membrane.cmd, aREADME.md(andrun-docker.*where the category offers Docker), so the reader can actually start it. - An integration test under
distribution/src/test/java/com/predic8/membrane/tutorials/…so the tutorial can't silently rot. These tests unzip the built distribution and start Membrane against the tutorial's YAML, so a broken example fails CI.
A tutorial step can also be a plain .md file — use this when the step needs no local
Membrane config (e.g. a curl-only walkthrough against a hosted API). A .md step gets no
integration test; it just lives alongside the numbered YAMLs and is linked from the README.
Work through the steps below in order. The reader of a tutorial follows the file top-to-bottom with no other docs open, so the single most important thing is that the YAML teaches itself.
Step 1 — Choose the category and filename
Categories live under distribution/tutorials/: getting-started, json, xml, advanced,
transformation, security, jwt, api-keys, oauth2, soap, soap-rest-converter,
wsdl-to-openapi, orchestration, sse, mcp, llm-gateway. Pick the one that fits; only
create a new category if nothing fits (see "New category" at the end).
Files are numbered NN-Title.yaml (e.g. 10-PathParameters.yaml). The number sets reading
order. List the directory and pick the next gap — convention leaves room between numbers
(10, 20, 30…) so steps can be inserted later. Match the existing PascalCase-with-hyphens
title style.
Step 2 — Write the YAML (the lesson lives here)
Open a sibling file in the same category and mirror its shape. Every tutorial YAML has the same skeleton:
# yaml-language-server: $schema=https://www.membrane-api.io/v7.2.4.json
#
# Tutorial: <Human Readable Name>
#
# <One sentence on what this teaches.>
#
# 1.) Start Membrane:
# ./membrane.sh -c NN-Title.yaml
#
# 2.) Call the API:
# curl localhost:2000/...
#
# <Expected output — paste it verbatim.>
#
# 3.) Continue with file NN-Next.yaml # only in sequential tutorials, see below
api:
port: 2000
...
# Troubleshooting:
# <common mistake and its fix>
#
# NOTE: <caveat, alternative or background>
#
# See also:
# - ../<category> folder for <related topic>Hold to these conventions — they're what makes the set feel like one coherent course:
- Pin the schema line to whatever sibling files use (grep one:
grep -m1 schema= distribution/tutorials/<category>/*.yaml). It tracks the current release version, so don't invent a number. - The reader must reach the config without scrolling. If something concrete only shows up after two pages of comments, the reader leaves. The top block holds the title, a one- or two-sentence intro and the numbered steps — nothing else.
- Keep the comment block short. Steps are a command and its expected output — nothing more.
Don't explain what the config does; the reader can see the config. Don't repeat information
the
name:field already provides. - Show expected output only when it helps tell the story and is short. A status line or a
one- or two-line body is fine. Shorten long JSON to the interesting part with
..., and leave out output the reader can derive from the config (e.g. one log line per visiblelog.info). - No section-header comments above each
api:block. Thename:field describes the API. - No trailing
# ...after a command in a step. Readers copy the line into their shell, and Windowscmddoesn't treat#as a comment, so it would pass the text to the command. Put prompts and notes on their own line:
Show every prompt an interactive tool asks, in order (e.g.# curl -u alice localhost:2000 # enter password: secrethtpasswdalso asksRe-type new password:), so the reader isn't surprised by one the step left out. Everything that is not a step goes at the end of the file, after the config, as one comment block (sections separated by a
#line) in this order:Troubleshooting:— common mistakes and their fix (e.g. a missingContent-Type: application/json)NOTE:— caveats, alternatives, background (unsupported hash formats, other databases, "plaintext only for demos")See also:— related tutorial folders or files as relative paths (../scripting)
Each of them would otherwise push the config further down.
- Inline comments only for the non-obvious WHY — a surprising built-in, a hidden constraint. Never comment what the interceptor name already says.
- Keep the tutorial short: every line must contribute to the story or to what the step teaches. This applies to the config, the comments and the tail alike. Cut interceptors, log lines, steps, notes and comments the lesson doesn't need, and merge notes that say related things into one. Lines that make the behavior visible do contribute, e.g. log lines that show which parts of the flow run in one case and not in the other. Tutorials favor clarity over completeness.
- Say "interceptor", not "plugin", in comments and notes.
- Port 2000 is the house convention for tutorial listeners unless the lesson needs more.
- Use
return: status: 200notreturn: {}. - "Continue with file NN-Title.yaml" only where the reader goes through the files in order:
getting-started/,advanced/, and numbered sub-step series within a topic (e.g. 20, 21, 22, 23). Every other category (routing, security, openapi, ...) is random access, so its files get no "Continue with" pointer. When adding to a sequential set, end the previous file's comment block with a pointer to the new one.
Step 3 — Make the category runnable
The reader runs ./membrane.sh -c <file> from the category directory, so that directory needs
the launcher scripts and a README.
- If
membrane.sh/membrane.cmdare missing from the category dir, copy them verbatim from a sibling category — they are identical generic launchers that walk up to findMEMBRANE_HOME. - Copy
run-docker.sh/run-docker.cmdonly if the category documents a Docker workflow. README.md: the category README points at the first file in the chain ("open NN-First.yaml and follow the instructions there"). If you added the first file of a new category, write this README modeled on a sibling's.
Step 4 — Write the integration test (don't skip this)
Without a test the example will drift out of sync with the code and break unnoticed — that's the whole reason these tests exist. The harness starts Membrane from the built distribution with your YAML and lets you assert against the live gateway.
Test package mirrors the category but with underscores: dir getting-started →
package com.predic8.membrane.tutorials.getting_started. The ExampleTests @Suite selects the
whole com.predic8.membrane.tutorials package, so a test placed correctly is auto-discovered
— no registration needed.
Each category has an Abstract<Category>TutorialTest that fixes getTutorialDir() (this is where
the hyphen dir name is restored). Your concrete test extends it, names the YAML, and asserts:
/* <copy the Apache 2.0 license header verbatim from a sibling test — keep its year> */
package com.predic8.membrane.tutorials.<category_with_underscores>;
import org.junit.jupiter.api.Test;
import static io.restassured.RestAssured.given;
import static org.hamcrest.CoreMatchers.containsString;
public class <Name>TutorialTest extends Abstract<Category>TutorialTest {
@Override
protected String getTutorialYaml() {
return "NN-Title.yaml";
}
@Test
void <whatItVerifies>() {
// @formatter:off
given()
.when()
.get("http://localhost:2000/...")
.then()
.statusCode(200)
.body(containsString("..."));
// @formatter:on
}
}Notes:
- Copy the license header from an existing sibling test rather than retyping it, so the year and wording match the repo.
- Assert the observable behavior the YAML comments promise in Step 2 — if the lesson says "you should see Customer: 7", assert exactly that. The test is the executable form of the lesson.
- If you created a brand-new category, also create its
Abstract<Category>TutorialTestmodeled on an existing one — it just returns the hyphenated dir name fromgetTutorialDir(). - Sub-categories (e.g.
llm-gateway/google) need their own abstract base returning the full relative path (llm-gateway/google), not just the top-level category abstract. Model onAbstractAiTutorialTest/AbstractGoogleTutorialTestindistribution/src/test/java/com/predic8/membrane/tutorials/. .mdsteps have no integration test — skip this step for them.
Step 5 — Verify
Run the test through the existing run-example-test skill. Pass -b so the distribution is
rebuilt first: the tutorial YAML ships inside distribution/target/*.zip, and the tests run
from the unzipped distribution, so an un-rebuilt run would test the old YAML (or none).
.claude/skills/run-example-test/run-example-test.sh -b <Name>TutorialTestA green run means the example actually starts and behaves as the lesson claims.
Common pitfalls
Template JSON auto-quoting
When a template interceptor has contentType: application/json, the engine automatically
adds quotes around every ${...} interpolation. Writing "${expr}" produces ""value"" and
breaks JSON. Always write interpolations unquoted:
- template:
contentType: application/json
src: |
{
"sub": ${user()},
"aud": "demo-resource"
}String literals that are not interpolated keep their quotes as normal.
Built-in functions in Groovy templates
Prefer the built-ins over raw property access:
user()— authenticated username (frombasicAuthenticationsecurity scheme)scopes()— list of granted scopeshasScope("read")— boolean scope check
Avoid the verbose ${property.'membrane.security.schemes'[0].username} — use ${user()} instead.
New category (only when nothing fits)
distribution/tutorials/<new-category>/with the firstNN-*.yaml,membrane.sh,membrane.cmd, and aREADME.md.- Add a section linking the new category in
distribution/tutorials/README.md. - Create
com.predic8.membrane.tutorials.<new_category>.Abstract<NewCategory>TutorialTestextendingAbstractMembraneTutorialTest, returning the hyphenated dir fromgetTutorialDir(). - Add concrete tests as in Step 4.
Checklist
NN-Title.yaml(or.mdfor curl-only steps) created with schema line, short numbered comment block, minimal config- Comment block: steps = command + expected output only; no prose repeating the config
- No trailing
# ...on command lines (Windowscmdpasses it to the command); prompts on their own line - Config visible without scrolling: top block = title, short intro, steps only
- Every line serves the story: no extra interceptors, log lines, steps, notes or comments
- "Interceptor", not "plugin"
- Expected output only where it helps and is short; long JSON shortened with
... Troubleshooting:,NOTE:,See also:after the config, in that order, as one comment block- No section-header comments above
api:blocks;name:describes them return: status: 200used (notreturn: {})- Template interpolations unquoted when
contentType: application/json - Previous file points to it ("Continue with…") only in a sequential set (getting-started, advanced, NN/NN+1 sub-step series); none in random-access categories
- Category has
membrane.sh,membrane.cmd,README.md(andrun-docker.*if used) <Name>TutorialTestin the underscore package, extends the category abstract base, has the license header- Sub-category has its own abstract base returning the full relative path
.mdsteps have no integration test- Assertions match the behavior the YAML comments promise
run-example-test.sh -b <Name>TutorialTestis green
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

