> ## Documentation Index
> Fetch the complete documentation index at: https://docs.bastani.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Extension examples

> Runnable extension examples shipped with Atomic.

# Extension examples

## Examples Reference

All examples in [examples/extensions/](https://github.com/bastani-inc/atomic/tree/main/packages/coding-agent/examples/extensions).

| Example                        | Description                                                                                                         | Key APIs                                                                                                                          |
| ------------------------------ | ------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------- |
| **Tools**                      |                                                                                                                     |                                                                                                                                   |
| `hello.ts`                     | Minimal tool registration                                                                                           | `registerTool`                                                                                                                    |
| `question.ts`                  | Width-wrapped single-question custom UI with option descriptions and typed answers                                  | `registerTool`, `ui.custom`                                                                                                       |
| `questionnaire.ts`             | Width-wrapped multi-step wizard with tab navigation and typed answers                                               | `registerTool`, `ui.custom`                                                                                                       |
| `todo.ts`                      | Stateful tool with persistence                                                                                      | `registerTool`, `appendEntry`, `renderResult`, session events                                                                     |
| `dynamic-tools.ts`             | Register tools after startup and during commands                                                                    | `registerTool`, `session_start`, `registerCommand`                                                                                |
| `structured-output.ts`         | Opt-in schema-specific `structured_output` tool using the canonical factory                                         | `createStructuredOutputTool`, `registerTool`, terminating tool results                                                            |
| `truncated-tool.ts`            | Output truncation example                                                                                           | `registerTool`, `truncateHead`                                                                                                    |
| `tool-override.ts`             | Override built-in read tool                                                                                         | `registerTool` (same name as built-in)                                                                                            |
| **Commands**                   |                                                                                                                     |                                                                                                                                   |
| `pirate.ts`                    | Modify system prompt per-turn                                                                                       | `registerCommand`, `before_agent_start`                                                                                           |
| `summarize.ts`                 | Conversation summary command                                                                                        | `registerCommand`, `ui.custom`                                                                                                    |
| `handoff.ts`                   | Cross-provider model handoff                                                                                        | `registerCommand`, `ui.editor`, `ui.custom`                                                                                       |
| `qna.ts`                       | Q\&A with custom UI                                                                                                 | `registerCommand`, `ui.custom`, `setEditorText`                                                                                   |
| `send-user-message.ts`         | Inject user messages                                                                                                | `registerCommand`, `sendUserMessage`                                                                                              |
| `reload-runtime.ts`            | Reload command and LLM tool handoff                                                                                 | `registerCommand`, `ctx.reload()`, `sendUserMessage`                                                                              |
| `shutdown-command.ts`          | Graceful shutdown command                                                                                           | `registerCommand`, `shutdown()`                                                                                                   |
| **Events & Gates**             |                                                                                                                     |                                                                                                                                   |
| `permission-gate.ts`           | Block dangerous commands                                                                                            | `on("tool_call")`, `ui.confirm`                                                                                                   |
| `protected-paths.ts`           | Block writes to specific paths                                                                                      | `on("tool_call")`                                                                                                                 |
| `confirm-destructive.ts`       | Confirm session changes                                                                                             | `on("session_before_switch")`, `on("session_before_fork")`                                                                        |
| `dirty-repo-guard.ts`          | Warn on dirty git repo                                                                                              | `on("session_before_*")`, `exec`                                                                                                  |
| `input-transform.ts`           | Transform user input                                                                                                | `on("input")`                                                                                                                     |
| `input-transform-streaming.ts` | Streaming-aware input transform                                                                                     | `on("input")`, `streamingBehavior`                                                                                                |
| `project-trust.ts`             | Decide or defer project trust from a user/global or CLI extension                                                   | `on("project_trust")`, trust UI, required trust result                                                                            |
| `model-status.ts`              | React to model changes                                                                                              | `on("model_select")`, `setStatus`                                                                                                 |
| `provider-payload.ts`          | Inspect payloads and provider response headers                                                                      | `on("before_provider_request")`, `on("after_provider_response")`                                                                  |
| `system-prompt-header.ts`      | Display system prompt info                                                                                          | `on("agent_start")`, `getSystemPrompt`                                                                                            |
| `claude-rules.ts`              | Load rules from files                                                                                               | `on("session_start")`, `on("before_agent_start")`                                                                                 |
| `prompt-customizer.ts`         | Add context-aware tool guidance using `systemPromptOptions`                                                         | `on("before_agent_start")`, `BuildSystemPromptOptions`                                                                            |
| `file-trigger.ts`              | File watcher triggers messages                                                                                      | `sendMessage`                                                                                                                     |
| **Compaction & Sessions**      |                                                                                                                     |                                                                                                                                   |
| `custom-compaction.ts`         | Offline compacted-text override                                                                                     | `on("session_before_compact")`                                                                                                    |
| `trigger-compact.ts`           | Trigger compaction manually                                                                                         | `compact()`                                                                                                                       |
| `git-checkpoint.ts`            | Git stash on turns                                                                                                  | `on("turn_start")`, `on("session_before_fork")`, `exec`                                                                           |
| `auto-commit-on-exit.ts`       | Commit on shutdown                                                                                                  | `on("session_shutdown")`, `exec`                                                                                                  |
| **UI Components**              |                                                                                                                     |                                                                                                                                   |
| `status-line.ts`               | Footer status indicator                                                                                             | `setStatus`, session events                                                                                                       |
| `working-indicator.ts`         | Customize the Working indicator used during prompt startup and active turns                                         | `setWorkingIndicator`, `registerCommand`                                                                                          |
| `github-issue-autocomplete.ts` | Add `#1234` issue completions on top of built-in autocomplete by preloading recent open issues from `gh issue list` | `addAutocompleteProvider`, `on("session_start")`, `exec`                                                                          |
| `custom-footer.ts`             | Replace footer entirely                                                                                             | `registerCommand`, `setFooter`                                                                                                    |
| `custom-header.ts`             | Replace startup header                                                                                              | `on("session_start")`, `setHeader`                                                                                                |
| `modal-editor.ts`              | Vim-style modal editor                                                                                              | `setEditorComponent`, `CustomEditor`                                                                                              |
| `rainbow-editor.ts`            | Custom editor styling                                                                                               | `setEditorComponent`                                                                                                              |
| `widget-placement.ts`          | Widget above/below editor                                                                                           | `setWidget`                                                                                                                       |
| `overlay-test.ts`              | Overlay components                                                                                                  | `ui.custom` with overlay options                                                                                                  |
| `overlay-qa-tests.ts`          | Comprehensive overlay tests                                                                                         | `ui.custom`, all overlay options                                                                                                  |
| `notify.ts`                    | Simple notifications                                                                                                | `ui.notify`                                                                                                                       |
| `timed-confirm.ts`             | Dialogs with timeout                                                                                                | `ui.confirm` with timeout/signal                                                                                                  |
| `mac-system-theme.ts`          | Auto-switch theme                                                                                                   | `setTheme`, `exec`                                                                                                                |
| **Complex Extensions**         |                                                                                                                     |                                                                                                                                   |
| `plan-mode/`                   | Full plan mode implementation                                                                                       | All event types, `registerCommand`, `registerShortcut`, `registerFlag`, `setStatus`, `setWidget`, `sendMessage`, `setActiveTools` |
| `preset.ts`                    | Saveable presets (model, tools, thinking)                                                                           | `registerCommand`, `registerShortcut`, `registerFlag`, `setModel`, `setActiveTools`, `setThinkingLevel`, `appendEntry`            |
| `tools.ts`                     | Toggle tools on/off UI                                                                                              | `registerCommand`, `setActiveTools`, `SettingsList`, session events                                                               |
| **Remote & Sandbox**           |                                                                                                                     |                                                                                                                                   |
| `ssh.ts`                       | SSH remote execution                                                                                                | `registerFlag`, `on("user_bash")`, `on("before_agent_start")`, tool operations                                                    |
| `interactive-shell.ts`         | Persistent shell session                                                                                            | `on("user_bash")`                                                                                                                 |
| `sandbox/`                     | Sandboxed tool execution                                                                                            | Tool operations                                                                                                                   |
| `gondolin/`                    | Route built-in tools and `!` commands into a Gondolin micro-VM                                                      | Tool operations, built-in tool overrides, `on("user_bash")`                                                                       |
| `subagent/`                    | Spawn sub-agents                                                                                                    | `registerTool`, `exec`                                                                                                            |
| **Games**                      |                                                                                                                     |                                                                                                                                   |
| `snake.ts`                     | Snake game                                                                                                          | `registerCommand`, `ui.custom`, keyboard handling                                                                                 |
| `space-invaders.ts`            | Space Invaders game                                                                                                 | `registerCommand`, `ui.custom`                                                                                                    |
| `doom-overlay/`                | Doom in overlay                                                                                                     | `ui.custom` with overlay                                                                                                          |
| **Providers**                  |                                                                                                                     |                                                                                                                                   |
| `custom-provider-anthropic/`   | Custom Anthropic proxy                                                                                              | `registerProvider`                                                                                                                |
| `custom-provider-gitlab-duo/`  | GitLab Duo integration                                                                                              | `registerProvider` with OAuth                                                                                                     |
| **Messages & Communication**   |                                                                                                                     |                                                                                                                                   |
| `message-renderer.ts`          | Custom message rendering                                                                                            | `registerMessageRenderer`, `sendMessage`                                                                                          |
| `event-bus.ts`                 | Inter-extension events                                                                                              | `pi.events`                                                                                                                       |
| **Session Metadata**           |                                                                                                                     |                                                                                                                                   |
| `session-name.ts`              | Name sessions for selector                                                                                          | `setSessionName`, `getSessionName`                                                                                                |
| `bookmark.ts`                  | Bookmark entries for /tree                                                                                          | `setLabel`                                                                                                                        |
| **Misc**                       |                                                                                                                     |                                                                                                                                   |
| `inline-bash.ts`               | Inline bash in tool calls                                                                                           | `on("tool_call")`                                                                                                                 |
| `bash-spawn-hook.ts`           | Adjust bash command, cwd, and env before execution                                                                  | `createBashTool`, `spawnHook`                                                                                                     |
| `with-deps/`                   | Extension with npm dependencies                                                                                     | Package structure with `package.json`                                                                                             |

## Next steps

Use the [Extension API reference](/extensions/api-reference) to check the context properties and method contracts used by these examples.
