AI-Powered Elixir Development with Ampcode
What is Amp?
Amp is an agentic coding tool by Sourcegraph. Install it from the manual. You get $10 USD free usage, then pay-as-you-go.
IEx Integration
Put the Amp configuration in ~/.iex.exs (global) or .iex.exs (project-local). IEx loads the first one it finds.
Complete configuration: https://gist.github.com/llk23r/5ee15677ac7e177f33dfbee8e7a96045
Start IEx:
iex -S mixYou’ll see:
❯ iexErlang/OTP 28 [erts-16.0.1] [source] [64-bit] [smp:10:10] [ds:10:10:10] [async-threads:1] [jit] [dtrace]
Interactive Elixir (1.18.4) - press Ctrl+C to exit (type h() ENTER for help)🚀 Amp CLI loaded
Basic usage: q() - Ask a question (clean output) q("thread_id") - Ask in specific thread
Livebook-friendly (no interactive input): q_livebook(prompt) - Ask with prompt directly q_livebook(prompt, id) - Ask in specific thread q_livebook_json(prompt) - Ask with JSON output q_livebook_auto(prompt) - Ask with auto-execution q_livebook_private(prompt) - Ask in private thread q_livebook_team(prompt) - Ask in team thread
Thread management: q_new() - Create new thread q_continue(id) - Continue specific thread q_fork(id) - Fork existing thread q_list() - List all threads q_share(id, vis) - Share thread (public/private/team) q_compact(id) - Compact thread q_status() - Show active thread
Tools & Utilities: q_tools() - Show available tools
Quick variants: q_json() - Ask with JSON output q_auto() - Ask with auto-execution q_private() - Ask in private thread q_team() - Ask in team thread
Management functions return {:ok, result} | {:error, reason}.Main q() function returns :ok for clean output.
iex(1)>Demo: IEx Usage
Livebook Integration
- Start named IEx node:
iex --name test@127.0.0.1 --cookie mycookie -S mix- Start Livebook:
livebook server --port 8080-
Connect Livebook to IEx:
- Runtime Settings → Attached node
- Name:
test@127.0.0.1 - Cookie:
mycookie
-
Import in first cell:
import AmpIExUsage Examples
# Generate documentationq_livebook("Create a README.md for this project")
# Generate codeq_livebook("Create a GenServer for handling user sessions")
# Generate testsq_livebook("Generate tests for my UserController module")
# Code improvementsq_livebook("Document this function with proper @doc annotations")q_livebook("Improve this function's performance and readability")Livebook-Specific Commands
The AmpIEx module provides several Livebook-optimized functions:
| Command | Purpose | Example |
|---|---|---|
q_livebook(prompt) | Basic query with direct prompt | q_livebook("Explain this code") |
q_livebook_json(prompt) | Returns structured JSON output | q_livebook_json("List project dependencies") |
q_livebook_auto(prompt) | Auto-executes suggested commands | q_livebook_auto("Install missing dependencies") |
q_livebook_private(prompt) | Creates private thread | q_livebook_private("Review sensitive config") |
q_livebook_team(prompt) | Creates team-visible thread | q_livebook_team("Share debugging approach") |
Daily Workflow
IEx: Start project with iex -S mix, use q() for AI assistance.
Livebook: Start named node, connect Livebook, import AmpIEx, use q_livebook() for non-interactive queries.
The integration feels seamless. AI assistance is always one function call away.