Skip to main content
All 33 files here live in examples/ in the repository and are exercised by the test suite — what you see below is exactly what’s on disk, not a simplified retelling. Run any of them yourself with sense run examples/<name>.sns (see Installation if sense isn’t on your PATH yet). A few near the end need a real ANTHROPIC_API_KEY to do anything interesting — those check for the key first and print a skip message if it’s missing, so they’re always safe to run.

Getting started

hello.sns — the smallest Sense program

fib.sns — functions, recursion, typed return

See also: Functions · Control Flow

arrays_and_loops.sns — arrays, for/in, break/continue

See also: Arrays

modules/ — splitting a program across files

modules/math_utils.sns
modules/main.sns
See also: Modules

python_interop.sns — reaching into any installed Python package

See also: Python Interop

testing.sns — the built-in testing framework

See also: Testing

docstrings_basics.sns.doc on functions, tools, actions, and agents

A bare string as the first statement of a function/tool/action/agent body is captured as .doc — nothing new to write, that string was already legal there. sense inspect shows it in every panel. See also: Functions: Docstrings

Safety and control

actions_and_policy.sns — prepare → verify → commit, and capability policy

See also: Actions · Policy

action_rollback.snsrollback: and action.rollback()

See also: Rollback

reversible_db_register.sns — a reversible action that isn’t a file

The reversible effect being tracked is “this row exists” — SQLite is just the storage; rollback: really deletes the row it just inserted. See also: Rollback · Python Interop

dry_run_basics.sns — preview what would commit, without letting it

Run it without --dry-run and every "-> actually ..." line prints for real. With it, those lines vanish completely — every capability check still runs for real, only the body that performs the effect is skipped. See also: Actions: Dry run · CLI Reference

real_email_action.sns — a real side effect, gated and previewable

Needs a local smtp4dev instance to actually send anything — email.send is irreversible on purpose, since an email can’t be unsent. Preview it with no smtp4dev running at all:
See also: Python Interop · Actions: Dry run

approval_and_audit.sns — mandatory approval and the audit log

See also: Actions · Pause & Resume

policy_library.sns + policy_true_potential.sns — one library, three trust levels

A shared capability library declares no policy of its own — what’s actually allowed is entirely up to whoever imports it:
policy_library.sns
policy_true_potential.sns
Same imported code, three independent sessions, three different sets of permissions — nothing about policy_library.sns changed between them. A capability check resolves against the caller’s scope, not the declaration’s, so this is real gating, not documentation. See also: Policy · Variables & Scope

Agents, sessions, and pausing

session_and_agent.sns — a scope vs. a runtime entity

See also: Sessions · Agents

agent_pause_resume.sns — suspending and resuming mid-body

See also: Pause & Resume

ask_human.sns — human-in-the-loop, built on pause/resume

See also: Pause & Resume

async_basics.sns — opt-in concurrency for agent and tool

See also: Agents · Tool

agent_communication.snssend/receive between concurrent agents

Each agent gets its own mailbox the moment it’s declared. send() never blocks; receive() blocks that agent’s own thread until something arrives. Sharing a plain variable between two async agents instead would race — this is the safe way to hand data between them. See also: Agents: Communication

Memory

memory_basics.sns — a session-scoped key/value store

See also: Memory

persistent_memory_basics.sns — durable, versioned storage

See also: Memory

tool_basics.sns — capability-checked functions

See also: Tool

Real LLM integration

Every example in this section checks for ANTHROPIC_API_KEY first and prints a skip message if it’s not set — safe to run without a key, but you’ll only see the interesting output with one configured. See Installation for the [anthropic]/[mcp] optional extras these need.

ask_basics.sns — model / ask / answer, fully offline

See also: Model, Ask & Answer

real_model_basics.sns — a real provider, inference("anthropic", ...)

See also: Model, Ask & Answer

real_model_openai_basics.sns — the same shape, a second vendor

Identical to real_model_basics.sns with "anthropic" swapped for "openai" — nothing else changes. One function for every real provider, not a separate one to learn per vendor. See also: Model, Ask & Answer

ask_with_tools_basics.sns — a model choosing which tool to call

See also: Tool-Calling

memory_wired_into_reasoning.sns — retrieval and write-back

See also: Memory: reasoning with memory · Tool-Calling

skills_basics.sns — bundling tools under one description

See also: Skills

mcp_client_basics.sns — tools from an external MCP server

See also: MCP

Putting it together

incident_response/ — an SRE copilot, every feature for a real reason

One coherent scenario, not a checklist: three incidents come off a monitoring feed; for each, two diagnostics run concurrently and report to a coordinator; then, based on severity, the incident is auto-remediated (low) or escalated to a human (high) — enforced by a session-scoped policy, not just an if/else, so a branching-logic bug still can’t auto-remediate a high-severity incident.
incident_response/runbook_library.sns
incident_response/main.sns
Every diagnostic decision, every remediation, every page — all in the audit_log() printed at the end, with (via agent:...) showing exactly which concurrent agent triggered which call. See also: Actions · Agents · Policy · Memory

Continue

Keywords reference

Every keyword used above, with full syntax and when to reach for it.

Quickstart

A guided first program, if you’d rather start smaller than this page.