RTFS Grammar
A grammar reference for the RTFS pure functional language used by agents.
Install
mkdir -p .claude/skills/rtfs-grammar && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/14714" && unzip -o skill.zip -d .claude/skills/rtfs-grammar && rm skill.zipInstalls to .claude/skills/rtfs-grammar
Activation
This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.
Learn RTFS (Reason about The Functional Spec) - the pure functional language for CCOS agentsKey capabilities
- →Define global variables using `def`
- →Bind lexical variables with `let`
- →Create anonymous and named functions
- →Implement conditional logic with `if`
- →Sequence expressions using `do`
- →Perform pattern matching with `match`
How it works
RTFS is a pure functional language using S-expression syntax where all side effects are delegated to the host via `(call ...)`, allowing for arithmetic, data transformation, and control flow.
Inputs & outputs
When to use RTFS Grammar
- →Learning agent language syntax
- →Writing RTFS-based agent scripts
About this skill
RTFS Grammar Reference
RTFS is a pure functional language using S-expression syntax, designed for LLM agents. All side effects are delegated to the host via (call ...).
Quick Reference
Core Syntax
;; Lists = code/function calls
(+ 1 2 3) ; => 6
(if (> x 0) "positive" "zero")
;; Vectors = ordered data
[1 2 3 4] ; literal vector
(get [10 20 30] 1) ; => 20
;; Maps = key-value data
{:name "Alice" :age 30} ; map literal
(get {:a 1 :b 2} :a) ; => 1
Literals
42 ; integer
3.14 ; float
"hello world" ; string (UTF-8)
true / false ; booleans
nil ; null/empty
:keyword ; self-evaluating keyword
:my.ns/qualified ; namespaced keyword
2026-01-28T10:00:00Z ; ISO 8601 timestamp
Variable Binding
(def pi 3.14159) ; global definition
(let [x 1 y (+ x 2)] ; lexical scoping
(* x y)) ; => 3
;; Destructuring
(let [[a b] [1 2]] (+ a b)) ; vector => 3
(let [{:keys [name age]} {:name "Al" :age 30}]
name) ; map => "Al"
Functions
(fn [x] (* x x)) ; anonymous function
(defn add [x y] (+ x y)) ; named function
(defn sum [& args] ; variadic (rest args)
(reduce + 0 args))
Control Flow
(if (> x 0) "positive" "non-positive")
(do ; sequencing
(call "ccos.io.log" "step1")
(call "ccos.io.log" "step2")
42) ; returns last expr
(match value ; pattern matching
0 "zero"
[x y] (str "pair: " x y)
{:name n} (str "hi " n)
_ "other")
The Host Boundary (CRITICAL)
RTFS is pure - it cannot perform side effects directly. All effects (I/O, network, state) must go through the host via (call ...):
;; Pure code (no call needed)
(+ 1 2 3) ; arithmetic
(map inc [1 2 3]) ; data transformation
(filter even? [1 2 3 4]) ; filtering
;; Effectful code (REQUIRES call)
(call "ccos.io.log" "Hello") ; I/O
(call "ccos.network.http-fetch" url) ; network
(call "ccos.io.read-file" "/path") ; file system
(call "ccos.state.kv.get" :key) ; state access
Built-in Capabilities
;; Data transformation
(call "ccos.json.parse" "{\"a\": 1}") ; => {:a 1}
(call "ccos.json.stringify" {:a 1}) ; => "{\"a\":1}"
;; System
(call "ccos.system.get-env" "PATH") ; => "/usr/bin:..."
(call "ccos.system.current-time") ; => timestamp
;; I/O
(call "ccos.io.log" "message")
(call "ccos.io.read-file" "/tmp/foo")
(call "ccos.io.write-file" "/tmp/foo" "bar")
;; State
(call "ccos.state.kv.put" :key "value")
(call "ccos.state.kv.get" :key)
Type Expressions
RTFS supports gradual typing with schemas:
;; Primitive types
:int :float :string :bool :nil :any
;; Collection types
[:vector :int] ; vector of ints
[:tuple :string :int] ; fixed tuple
[:map [:name :string] [:age :int]] ; map schema
;; Function types
[:fn [:int :int] :int] ; (int, int) -> int
;; Union & Optional
[:union :int :string :nil] ; one of these types
:string? ; sugar for [:union :string :nil]
;; Refined types (constraints)
[:and :int [:> 0]] ; positive int
[:and :int [:>= 0] [:< 100]] ; int in [0, 100)
[:and :string [:min-length 1] [:max-length 255]]
Capability Definition
Capabilities are the core building blocks:
(capability "my-tool.fetch-data"
:description "Fetches data from API"
:input-schema [:map
[:id :string]
[:limit [:and :int [:> 0]]]]
:output-schema [:map [:data [:vector :any]]]
:effects [:network]
:implementation (fn [inputs]
(let [url (str "https://api.example.com/" (:id inputs))]
(call "ccos.network.http-fetch" {:url url}))))
Common Patterns
Multi-step workflow
(let [weather (call "weather.get" {:city "Paris"})
price (call "crypto.get-price" {:symbol "BTC"})
fact (call "catfact.random" {})]
{:weather weather :btc price :cat fact})
Error handling with match
(match (call "api.fetch" {:id "123"})
{:error e} (call "ccos.io.log" (str "Failed: " e))
{:data d} (process-data d)
_ (call "ccos.io.log" "Unknown response"))
Resources
- Full specs:
docs/rtfs-2.0/specs/ - REPL guide:
docs/rtfs-2.0/guides/repl-guide.md - Type checking:
docs/rtfs-2.0/guides/type-checking-guide.md
When not to use it
- →When direct side effects (I/O, network, state) are required without delegation
- →When working with languages other than RTFS
Limitations
- →Cannot perform side effects directly; all effects must go through the host via `(call ...)`
- →Uses S-expression syntax, which may be unfamiliar to users of imperative languages
- →Requires explicit capability definitions for host interactions
How it compares
RTFS is a pure functional language designed for LLM agents, explicitly delegating all side effects to a host via `(call ...)`, which differs from general-purpose languages that allow direct side effects.
Compared to similar skills
RTFS Grammar side by side with the closest alternatives in the catalog.
| Skill | Installs | Updated | Safety | Difficulty |
|---|---|---|---|---|
| RTFS Grammar (this skill) | 0 | 6mo | No flags | Intermediate |
| godot | 1,044 | 5mo | Review | Intermediate |
| software-architecture | 333 | 6mo | No flags | Intermediate |
| drizzle | 238 | 2mo | No flags | Intermediate |
Try saying
Example prompts that trigger this skill in your AI assistant.
You might also like
godot
bfollington
This skill should be used when working on Godot Engine projects. It provides specialized knowledge of Godot's file formats (.gd, .tscn, .tres), architecture patterns (component-based, signal-driven, resource-based), common pitfalls, validation tools, code templates, and CLI workflows. The `godot` command is available for running the game, validating scripts, importing resources, and exporting builds. Use this skill for tasks involving Godot game development, debugging scene/resource files, implementing game systems, or creating new Godot components.
software-architecture
davila7
Guide for quality focused software architecture. This skill should be used when users want to write code, design architecture, analyze code, in any case that relates to software development.
drizzle
lobehub
Drizzle ORM schema and database guide. Use when working with database schemas (src/database/schemas/*), defining tables, creating migrations, or database model code. Triggers on Drizzle schema definition, database migrations, or ORM usage questions.
screenshot-to-code
OneWave-AI
Convert UI screenshots into working HTML/CSS/React/Vue code. Detects design patterns, components, and generates responsive layouts. Use this when users provide screenshots of websites, apps, or UI designs and want code implementation.
zustand
lobehub
Zustand state management guide. Use when working with store code (src/store/**), implementing actions, managing state, or creating slices. Triggers on Zustand store development, state management questions, or action implementation.
codex
Lucklyric
Invoke Codex CLI for complex coding tasks requiring high reasoning capabilities. This skill should be invoked when users explicitly mention "Codex", request complex implementation challenges, advanced reasoning, or need high-reasoning model assistance. Automatically triggers on codex-related requests and supports session continuation for iterative development.