CHICKEN Scheme Skill
CHICKEN is a Scheme-to-C compiler + interpreter. It produces portable, efficient C from Scheme source and supports R5RS / R7RS (via extension). The main commands are:
| Command |
Purpose |
csi |
Interactive interpreter (REPL) |
csc |
Compiler driver (Scheme → C → native binary) |
chicken-install |
Install eggs (libraries) |
chicken-status |
List installed eggs |
chicken-uninstall |
Remove an egg |
Quick-Start Workflow
;;; hello.scm
(import (chicken base))
(print "Hello, world!")
# Interpreted
csi -s hello.scm
# Compiled to executable
csc hello.scm # produces ./hello
./hello
# Compiled as shared object (for loading into csi)
csc -shared hello.scm # produces hello.so
Egg System (Libraries)
chicken-install srfi-1 # list utilities
chicken-install matchable # pattern matching
chicken-install http-client # HTTP requests
chicken-install medea # JSON parser
# Search eggs online: https://wiki.call-cc.org/eggs
REPL Tips (csi)
,? ; help
,l file ; load a file
,t expr ; time an expression
,d name ; describe a binding
,q ; quit
Enable readline: chicken-install breadline, then add to ~/.csirc:
(import breadline)
(current-input-port (make-readline-port))
Common Pitfalls
csc on Windows may conflict with the C# compiler — use a full path or rename.
- No
use in CHICKEN 5 — replace (use foo) with (import foo).
- Dynamic loading requires a shared library on the
CHICKEN_REPOSITORY_PATH.
- CLI arguments: read via
(command-line-arguments) from (chicken process-context) — not (argv), and not Racket's command-line form.
call/cc is powerful but sharp — prefer high-level abstractions (threads, conditions) over raw continuations in application code.
- Unsafe mode (
-unsafe) disables all safety checks — only use for hot inner loops after profiling.
Integrated Example
Goal: a CLI tool that reads a JSON file and prints how many records it has.
;;; count.scm
(import (chicken base)
(chicken process-context) ; command-line-arguments
(chicken file) ; read-string
medea) ; egg: read-json — NOT (use medea)
(define data (with-input-from-file (car (command-line-arguments)) read-json))
(printf "~a records~%" (length data))
chicken-install medea # install the JSON egg first
csc count.scm # Scheme → C → ./count
./count records.json # => 42 records
The medea egg is pulled in with (import medea) — in CHICKEN 5 there is no use. csc
compiles to a native binary in one step; for quick iteration csi -s count.scm records.json
runs the same source interpreted.
Read On Demand
| Read When |
File |
| Modules, imports, tail recursion, call/cc, macros, records |
Core Language |
| Scripting, shebang, CLI tools, everyday compiler flag examples, egg structure |
Scripting & CLI |
| FFI: foreign-lambda, callbacks, C interop, embedding |
FFI Guide |
| Egg authoring, testing, and publishing workflow |
Egg System |
Full csi/csc flag reference, runtime options, (declare ...) reference, deployment/static linking |
CLI & Compiler Cheatsheet |
Benchmark
Scenario: .benchmarks/scenarios/chicken-scheme-001-chicken5-migration.md · Run: 2026-08-31 (salience re-run wf_9a5588bc) · Log: .benchmarks/runs/2026-08-31/chicken-scheme-001-chicken5-migration.json
| Model |
Without |
With |
Delta |
| claude-opus-4-8 |
83% |
100% |
+17% |
| claude-sonnet-4-6 |
100% |
100% |
+0% |
| claude-haiku-4-5 |
100% |
83% |
−17% |
SOFT PASS (run 2026-08-31). Salience re-run (process-context pitfall bullet + import added to the integrated example, wf_9a5588bc): opus's args-idiom miss cleared (+17). Haiku shows a one-criterion csc -static/-deploy dip on an untouched criterion — single-run noise suspect; targeted c4 re-run on the follow-up list. No edit left this cycle (cap reached). Gate per .agents/skills/skill-optimizer/rules/release-gates.md.
1---2name: chicken-scheme3description: Write, compile, debug, and package CHICKEN Scheme programs. Use this skill whenever the user mentions CHICKEN Scheme, call-cc.org, csc, csi, Scheme eggs, Scheme-to-C compilation, R5RS/R7RS Scheme, call/cc, continuations, SRFI, or wants help with any Scheme programming task using CHICKEN. Also trigger for questions about the CHICKEN FFI, C interop from Scheme, egg packaging, REPL usage, or scripting with csi. Even if the user just says "scheme" without specifying CHICKEN, use this skill if context suggests CHICKEN (e.g. they mention eggs, csc, chicken-install, or wiki.call-cc.org). DO NOT USE when: the user is working with another Scheme implementation (Racket, Guile, MIT Scheme, Gambit) — those have different module systems, package managers, and idioms.4---56# CHICKEN Scheme Skill78CHICKEN is a Scheme-to-C compiler + interpreter. It produces portable, efficient C from Scheme source and supports R5RS / R7RS (via extension). The main commands are:910| Command | Purpose |11| ------------------- | -------------------------------------------- |12| `csi` | Interactive interpreter (REPL) |13| `csc` | Compiler driver (Scheme → C → native binary) |14| `chicken-install` | Install eggs (libraries) |15| `chicken-status` | List installed eggs |16| `chicken-uninstall` | Remove an egg |1718---1920## Quick-Start Workflow2122```scheme23;;; hello.scm24(import (chicken base))25(print "Hello, world!")26```2728```bash29# Interpreted30csi -s hello.scm3132# Compiled to executable33csc hello.scm # produces ./hello34./hello3536# Compiled as shared object (for loading into csi)37csc -shared hello.scm # produces hello.so38```3940---4142## Egg System (Libraries)4344```bash45chicken-install srfi-1 # list utilities46chicken-install matchable # pattern matching47chicken-install http-client # HTTP requests48chicken-install medea # JSON parser4950# Search eggs online: https://wiki.call-cc.org/eggs51```5253---5455## REPL Tips (csi)5657```scheme58,? ; help59,l file ; load a file60,t expr ; time an expression61,d name ; describe a binding62,q ; quit63```6465Enable readline: `chicken-install breadline`, then add to `~/.csirc`:6667```scheme68(import breadline)69(current-input-port (make-readline-port))70```7172---7374## Common Pitfalls7576- **`csc` on Windows** may conflict with the C# compiler — use a full path or rename.77- **No `use` in CHICKEN 5** — replace `(use foo)` with `(import foo)`.78- **Dynamic loading** requires a shared library on the `CHICKEN_REPOSITORY_PATH`.79- **CLI arguments**: read via `(command-line-arguments)` from `(chicken process-context)` — not `(argv)`, and not Racket's `command-line` form.80- **`call/cc` is powerful but sharp** — prefer high-level abstractions (threads, conditions) over raw continuations in application code.81- **Unsafe mode** (`-unsafe`) disables all safety checks — only use for hot inner loops after profiling.8283---8485## Integrated Example8687**Goal:** a CLI tool that reads a JSON file and prints how many records it has.8889```scheme90;;; count.scm91(import (chicken base)92 (chicken process-context) ; command-line-arguments93 (chicken file) ; read-string94 medea) ; egg: read-json — NOT (use medea)9596(define data (with-input-from-file (car (command-line-arguments)) read-json))97(printf "~a records~%" (length data))98```99100```bash101chicken-install medea # install the JSON egg first102csc count.scm # Scheme → C → ./count103./count records.json # => 42 records104```105106The `medea` egg is pulled in with `(import medea)` — in CHICKEN 5 there is no `use`. `csc`107compiles to a native binary in one step; for quick iteration `csi -s count.scm records.json`108runs the same source interpreted.109110---111112## Read On Demand113114| Read When | File |115| ------------------------------------------------------------------------------------------------------ | ----------------------------------------------------- |116| Modules, imports, tail recursion, call/cc, macros, records | [Core Language](references/core-language.md) |117| Scripting, shebang, CLI tools, everyday compiler flag examples, egg structure | [Scripting & CLI](references/scripting-cli.md) |118| FFI: foreign-lambda, callbacks, C interop, embedding | [FFI Guide](references/ffi.md) |119| Egg authoring, testing, and publishing workflow | [Egg System](references/eggs.md) |120| Full `csi`/`csc` flag reference, runtime options, `(declare ...)` reference, deployment/static linking | [CLI & Compiler Cheatsheet](references/cheatsheet.md) |121122---123124## Benchmark125126Scenario: `.benchmarks/scenarios/chicken-scheme-001-chicken5-migration.md` · Run: 2026-08-31 (salience re-run `wf_9a5588bc`) · Log: `.benchmarks/runs/2026-08-31/chicken-scheme-001-chicken5-migration.json`127128| Model | Without | With | Delta |129| ----------------- | ------- | ---- | ----- |130| claude-opus-4-8 | 83% | 100% | +17% |131| claude-sonnet-4-6 | 100% | 100% | +0% |132| claude-haiku-4-5 | 100% | 83% | −17% |133134> **SOFT PASS (run 2026-08-31)**. Salience re-run (process-context pitfall bullet + import added to the integrated example, wf_9a5588bc): opus's args-idiom miss cleared (+17). Haiku shows a one-criterion `csc -static`/`-deploy` dip on an untouched criterion — single-run noise suspect; targeted c4 re-run on the follow-up list. No edit left this cycle (cap reached). Gate per `.agents/skills/skill-optimizer/rules/release-gates.md`.