swirls-lang
Installation
SKILL.md
Swirls Language
Comprehensive guide for authoring .swirls workflow files. Covers the full DSL: file structure, graph declarations, all 13 node types, TypeScript / JSON / SQL embedded blocks, the context object, resources, triggers, top-level stream blocks, reviews, failure policies, and known parser pitfalls.
When to Apply
- Writing new
.swirlsfiles from scratch. - Adding nodes, graphs, streams, or triggers to existing
.swirlsfiles. - Debugging parse errors or validation failures from
swirls doctor. - Writing
@tsblocks (TypeScript code in nodes). - Defining JSON Schemas for inputs, outputs, forms, and webhooks.
- Connecting graphs to forms, webhooks, or schedules via triggers.
- Persisting graph output with top-level
stream { }blocks and reading it withtype: streamnodes. - Configuring human-in-the-loop review blocks.
- Declaring external Postgres databases and writing parameterized SQL nodes.
Priority
| # | Category | Impact | Prefix | Rules |
|---|---|---|---|---|
| 1 | Language Spec | CRITICAL | spec- |
READ FIRST. Exhaustive list of valid syntax, keywords, node types, fields. If it is not listed here, it does not exist. |
| 2 | File Structure | HIGH | structure- |
Top-level declarations, file discovery, comment restrictions |
| 3 | Graph & Node Basics | CRITICAL | graph- |
Root node, flow block, edges, DAG rules |
| 4 | Node Types | CRITICAL | node- |
All 13 node types, required/optional fields, secrets map, failure policy |
| 5 | TypeScript Blocks | CRITICAL | ts- |
@ts patterns, sandbox limits, safe code |
| 6 | Schema & Typing | HIGH | schema- |
JSON Schema, inputSchema/outputSchema/schema placement |
| 7 | Context Object | HIGH | context- |
context.nodes, context.reviews, context.secrets, context.meta |
| 8 | Resources & Triggers | HIGH | resource- |
Forms, webhooks, schedules, secrets, auth blocks, postgres blocks, top-level stream blocks, trigger bindings |
| 9 | Streams | MEDIUM | stream- |
Filter operators, field paths, migration from persistence |
| 10 | Reviews | MEDIUM | review- |
Human-in-the-loop review config |
| 11 | Parser Pitfalls | CRITICAL | parser- |
Known parser bugs, silent drops, validator diagnostics |
Quick Reference
1. Language Spec (READ FIRST)
spec-strict-syntax- Exhaustive list of every valid keyword, node type, config field, edge syntax, and value type. If something is not listed here, it does not exist. Do not invent syntax.spec-common-mistakes- The 23 most common incorrect patterns with corrections. Check your output against these before returning any .swirls code.
2. File Structure
structure-top-level-declarations- The nine valid top-level blocks: form, webhook, schedule, graph, stream, trigger, secret, auth, postgresstructure-file-discovery- File extensions, discovery rules,.ts.swirlsfilesstructure-comments- Comment syntax and ASCII-only restriction
3. Graph & Node Basics
graph-anatomy- Graph structure: label, description, root, nodes, flow (persistence block removed)graph-root-node- Every graph needs exactly oneroot { }blockgraph-flow-block- Connecting nodes with edges and labeled edgesgraph-dag-rules- No cycles, one root, edge validation
4. Node Types (13 total)
node-code- Code nodes: sandboxed TypeScript executionnode-ai- AI nodes: text, object, image, video, embed kindsnode-switch- Switch nodes: conditional routing with casesnode-http- HTTP nodes: making API requestsnode-email- Resend nodes (type: resend): sending email via Resendnode-scrape- Firecrawl nodes (type: firecrawl): web scrapingnode-parallel- Parallel nodes: search / extract / findall operationsnode-stream- Stream nodes: reading persisted stream data with filtersnode-graph- Graph nodes: calling subgraphsnode-wait- Wait nodes: pausing executionnode-bucket- Bucket nodes: object storage upload/downloadnode-document- Document nodes: document processingnode-postgres- Postgres nodes: parameterized SELECT and INSERT against external databasesnode-secrets-map-secrets: { block: [VAR] }object-literal syntax (shared across types)node-failure-policy- OptionalfailurePolicy:for retry / skip / fallback behavior
5. TypeScript Blocks
ts-block-syntax-@ts { }inline blocks and@ts "file.ts.swirls"referencests-sandbox-limits- No imports, no fetch, no fs, no network in code nodests-safe-patterns- Always-safe patterns vs patterns to avoidts-no-double-quotes- UseString.fromCharCode(34)instead of literal double-quotets-no-nested-templates- Use concatenation instead of nested template literalsts-no-dollar-interpolation- Avoid$${}in template literalsts-no-nested-code-blocks- Never nest@ts/@jsonblocks inside other code blocks
6. Schema & Typing
schema-json-schema- JSON Schema format in@jsonblocksschema-input-output-inputSchema(root only),outputSchema(root only),schema(non-root); strict parser enforcementschema-inline-syntax- Inline object literal schema syntax (no@json)
7. Context Object
context-nodes- Accessing upstream node inputs and outputscontext-secrets- Declaring and accessing secretscontext-reviews- Accessing review form responsescontext-meta- Execution metadata (triggerId, triggerType)
8. Resources & Triggers
resource-form- Form declarations with label, schema, enabledresource-webhook- Webhook declarationsresource-schedule- Schedule declarations with cron and timezoneresource-stream- Top-levelstream { }blocks: graph, schema, condition, prepareresource-trigger-binding- Trigger syntax:resourceType:name -> graphName(form / webhook / schedule only)resource-secrets- Top-levelsecret { vars: [...] }blocksresource-auth- Top-levelauthblocks (oauth, api_key, basic, bearer, cloud) and http-nodeauth:referencesresource-postgres- Top-levelpostgresblocks: connection, table schemas, secret references
9. Streams
stream-persistence-block- Migration note:persistence { }removed; use top-levelstream { }stream-query-sql- SQL queries replaced byfilter: @ts { ... }returning aStreamFilterstream-column-naming- Filter field paths: table columns vs output JSON fields
10. Reviews
review-config- Review block structure, actions, and fieldsreview-access-downstream- Accessing review data in downstream nodes viacontext.reviews
11. Parser Pitfalls
parser-unicode-comments- Unicode in comments breaks line countingparser-hyphenated-headers- Hyphenated header keys parsed as subtractionparser-double-quotes-in-ts- Double-quote chars inside@tsblocks drop graphsparser-nested-templates- Nested template literals break@tsparsingparser-dollar-interpolation-$${}breaks@tsparsingparser-silent-drops- Parser silently drops graphs with no errorparser-cascade-errors- Parse errors cascade past the actual problemparser-validation-checklist- Pre-flight checklist before runningswirls doctorparser-validation-rules- Exhaustive list of validator diagnostics and how to fix each
How to Use
Individual rules live in rules/. Each file covers one concept with incorrect / correct examples.
For a single compiled document with all rules, see AGENTS.md.