Runnable examples demonstrating every public function of the Amp SDK for Elixir.
Prerequisite: The Amp CLI must be installed and authenticated (
amp login).
Behavior note: Some examples are optional and return exit code
20(skip) when prerequisites are missing.run_all.shreports these as skipped instead of passed/failed.
tools_make.exs: skips automatically if the installed Amp CLI requires interactive inputthreads_handoff_replay.exs: setAMP_RUN_REPLAY=1to run replaymcp_oauth.exs: setAMP_MCP_OAUTH_SERVERandAMP_MCP_OAUTH_SERVER_URLto run status/logout; setAMP_MCP_OAUTH_RUN_LOGIN=1to run login too
Run All
./examples/run_all.sh
./examples/run_all.sh --ssh-host example.internal
./examples/run_all.sh --ssh-host example.internal --danger-full-access
Or run individually:
mix run examples/<name>.exs
mix run examples/run_simple.exs -- --ssh-host example.internal
mix run examples/run_simple.exs -- --ssh-host example.internal --danger-full-access
Shared SSH Flags
Every example in this directory accepts the same optional SSH transport flags:
--cwd <path>passes an explicit working directory to the example--danger-full-accessmaps the example todangerously_allow_all: true--ssh-host <host>switches the example toexecution_surface: :ssh_exec--ssh-user <user>overrides the SSH user--ssh-port <port>overrides the SSH port--ssh-identity-file <path>sets the SSH identity file
If you omit the SSH flags, the examples keep the existing local subprocess default unchanged.
For Amp, --danger-full-access keeps the same transport placement and opts the
example into the permissive runtime flag that the Amp CLI already exposes.
Execute
| Example | Description |
|---|---|
| basic_execute.exs | Stream all message types with pattern matching |
| run_simple.exs | Blocking run/2 returning final result |
| create_user_message.exs | Multi-turn via create_user_message/1 |
| thinking.exs | Thinking blocks via --stream-json-thinking |
| no_ide_mode.exs | Headless flags: --no-ide, --no-notifications, --no-color |
| continue_thread.exs | Multi-turn conversation with thread continuation |
| with_permissions.exs | Fine-grained tool permissions via create_permission/3 |
Management
| Example | Description |
|---|---|
| usage.exs | Credit balance and usage info |
| tools_list.exs | List all available tools |
| tools_show.exs | Show tool schema (e.g., Read) |
| tools_use.exs | Invoke a tool directly |
| tools_make.exs | Create a new tool (auto-skips if CLI requires interactive input) |
| skills_list.exs | List installed skills |
| skills_manage.exs | Skill lifecycle: add, info, remove |
| permissions_list.exs | List permission rules |
| permissions_manage.exs | Test and add permissions |
| tasks_list.exs | List tasks |
| tasks_import.exs | Import tasks from JSON |
| review.exs | Code review with summary |
Threads
| Example | Description |
|---|---|
| threads.exs | Create thread + export as Markdown |
| thread_lifecycle.exs | Full lifecycle: create, rename, share, archive, delete |
| threads_list.exs | List all threads |
| threads_search.exs | Search threads by query |
| threads_handoff_replay.exs | Thread handoff and replay |
MCP
| Example | Description |
|---|---|
| mcp_list.exs | List configured MCP servers |
| mcp_doctor.exs | Check MCP server health |
| mcp_manage.exs | MCP lifecycle: add, approve, remove |
| mcp_oauth.exs | OAuth: status, login, logout |
Adding New Examples
- Create a
.exsfile in this directory - End with
System.halt(0)to prevent the BEAM from hanging - Add a
run_examplecall inrun_all.sh - Use
%Options{dangerously_allow_all: true}for non-interactive execution - Require
examples/support/example_helper.exs, callSupport.init!(), and applySupport.with_execution_surface/1orSupport.command_opts/1so the shared SSH and--danger-full-accessflags work consistently
Recovery-Oriented Examples
For the emergency hardening lane, the most relevant existing examples are:
examples/continue_thread.exsexamples/threads.exsexamples/thread_lifecycle.exs
examples/run_all.sh already includes the continuation and thread-management demos in its standard
execution sequence.