Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of fatscript?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/antonioprates-fatscript)
---
name: fatscript
description: Programming in FatScript (.fat files, fry interpreter) — syntax, stdlib, FFI/bridge, testing and project conventions, plus critical non-obvious semantics (dynamic scoping, closure capture, list/null behavior, block-vs-scope braces, error traps, worker isolation). Use whenever writing, reviewing, or debugging FatScript code.
---
# Programming in FatScript
FatScript is an interpreted, minimalist language run by `fry`; source files end
in `.fat`. Docs: https://fatscript.org. Interpreter and `sample/` set:
gitlab.com/fatscript/fry. Single-file libraries to imitate: postgres.fat,
zlib.fat, qrcode.fat (gitlab.com/aprates). `fry -x` exports the stdlib as
readable `.fat` files under `./fat/` — the source of truth for any API.
Load the reference that matches the task:
| File | Read before… |
| -------------------------- | --------------------------------------------------------------- |
| `references/semantics.md` | any non-trivial code, and ALWAYS when debugging odd behavior |
| `references/syntax.md` | writing code: operators, types, flow, loops, imports |
| `references/stdlib.md` | calling a `fat.*` module or a type prototype method |
| `references/idioms.md` | creating a library, test, README, app layout or CLI |
| `references/ffi.md` | anything with `fat.bridge` (C libraries, pointers, buffers) |
Everything below was verified on fry 4.7.0. If behavior differs, check
`fry --version` and probe before trusting either this skill or memory.
## Rules that prevent most bugs
Each is explained, with examples, in `references/semantics.md`.
**Scoping and closures**
1. Name resolution walks the live call stack (dynamic scoping), root last. A
lambda's free names resolve where it RUNS, so a wrapper's params shadow
the enclosing function's names. Give wrapper params and anything a lambda
reads across a wrapper distinctive names; never read an outer `m`, `key`,
`acc`, `item`, `val`, `i`, `n` inside a lambda nested in a List method.
2. A returned lambda captures its factory's params only when it IS the
factory's expression body: `f = (a) -> (x) -> a + x`. With a `{ ... }`
factory body, captured params and locals read as null.
3. `holder.fn(args)` pushes `holder`: args resolve against holder members
first (`time.format(now, ...)` works; a local named like a member is
shadowed). Entity methods don't see their module — capture module
internals onto `self` in `apply`.
4. Worker thunks run on a fresh stack: curry state in
(`task = (s) -> -> s.run; Worker(task(self))`).
**Assignment**
5. Values are immutable unless declared with `~`. Inside a lambda, plain
`x = x + 1` creates a local; only compound assigns (`+=`) and field writes
(`s.f = v`, `s.{ ... }`) reach outer entries.
6. A `~` variable passed as an argument is copied; an immutable is shared.
**Braces, lists, text**
7. `{...}` as a whole lambda body or a branch (`?`, `=>`, `??`) is a BLOCK.
Return a scope literal with parens: `-> ({ a = 1 })`, `c ? ({}) : ...`.
8. Lists are homogeneous and drop nulls; use a Scope for mixed/nullable data.
9. Single quotes interpolate `{expr}`. Regexes, JSON text and anything with
literal braces must be double-quoted. No escapes or nested same-quote
inside `{...}`: bind first, then interpolate the name.
**Errors**
10. Evaluating an Error value raises it (even `e = Error('x')`).
`failure.trapWith` unwinds: the handler's value becomes the installing
function's return value. A handler that returns an error re-raises it;
`err.raise` re-throws a stored one. `??` catches errors as well as null.
11. Don't pass a call that may raise straight into a typed param: the real
error becomes `TypeError: type mismatch`. Bind it first.
**Methods**
12. No `return` and no early exit: write guard clauses as `Cases` at the end
of the method, catch-all `_` last; move multi-step branches into their
own methods.
13. Niladic lambdas (`f = () -> ...`) need `f()`; procedures
(`f = Type <> ...`) run on bare reference.
## Tooling
- `fry file.fat` run; `fry -p` static check (TRO and implicit-param hints are
normal); `fry -f` in-place formatter (run before committing).
- `fry -i` REPL (statements end with `;`). Probe semantics quickly:
`printf 'expr;\n' | fry -i`. This language rewards probing; do it before
asserting a behavior.
- `fry -n <k>` caps nodes (GC stress test); `fry -b out in` bundles;
`fry -j` jails FS/network/system calls; `fry -e` continues on error.
- `fry - args...` runs source from STDIN. A numeric final value becomes the
exit code (mod 256): end scripts with a Text or guard result.
- Tests are plain scripts ending in `$result` and a guard to
`'pass'`/`'fail'`; skeleton in `references/idioms.md`.
- Minimum fry 4.6.0 for code written with this skill. Fixed long ago, don't
re-add workarounds for: raises inside handlers/`??` (now ordinary),
root bindings hijacking locals, `??` fallback blocks, null FFI pointers,
`List.shuffle` bias, Storable default backfill, `http.listen` crash on
handler error, `1.0E7` JSON exponents.