/livekit:building-livekit-agentsfrom LiveKit
Structures voice and chat AI agents with LiveKit Agents SDK and LiveKit Cloud. Covers architecture for latency, context management, agent handoffs, and voice design patterns.
Ships in LiveKit. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
This skill covers how to structure a voice agent. It has no API specifics, because those change;
get them from reading-livekit-docs.
It assumes LiveKit Cloud, the recommended path: managed infrastructure, plus LiveKit Inference for models so you don't manage per-provider API keys.
Where the agent runs and which LiveKit the project uses are separate questions. An agent the user self-hosts (on their own servers instead of LiveKit Cloud's agent hosting) still connects to LiveKit Cloud and can still use LiveKit Inference. Inference is a LiveKit Cloud feature, so it's only off the table when the project runs on LiveKit OSS. The architecture advice applies either way; on LiveKit OSS, models come from each provider's own plugin and API keys.
Use LiveKit Inference for each model that the agent uses: STT, LLM, TTS, or a realtime model. Many examples, and much of the LiveKit code that you remember, use a provider plugin for each model. Do not copy that pattern. Inference is better for these reasons:
For the LLM, start with Gemma through Inference. The reference examples in livekit/agents run on
it, so it is the most exercised choice. The model you remember from other examples is not a reason
to choose something else. Get the model name from reading-livekit-docs.
Use a provider plugin only when:
reading-livekit-docs; don't assume from memory)If the code already uses plugins, leave them unless the user asks you to change them. Mention Inference once as an option.
reading-livekit-docs and look up the APIs you're about to use. Don't write LiveKit
code from memory.LIVEKIT_URL, LIVEKIT_API_KEY, LIVEKIT_API_SECRET, usually in .env. The CLI can link a
project and write these. Linking opens a browser page the user has to approve, so ask them to do
it; you can't approve it yourself. Account-level work (creating or changing a project, reading
session data) needs a second kind of sign-in, as a LiveKit Cloud user, which also takes the
user's approval. If a command the docs describe is missing from --help, it may only appear
after that sign-in, so check before concluding it doesn't exist.operating-livekit-agents covers
checking it and asking the user before turning it on.debugging-livekit-agents (drive a
real conversation), testing-livekit-agents (assert on turns), or both, because it affects how
you factor the code.Some lk commands, such as scaffolding a project or creating a cloud agent, ask questions in menus
when they think a person is at the keyboard. You can't answer a menu, and faking a terminal to get
past one wastes turns. Pass --yes instead. It accepts every confirmation, and it turns each
remaining question into either a default or an error that names the flag to supply. When a command
fails that way, add the flag and run it again. Set LK_SOURCE=skills in the environment of each lk
command too, as reading-livekit-docs explains.
lk agent init my-agent --yes # see --help for the language, template, and install flags
Take the values from what the user asked for. When a command needs one the user hasn't given, such as which project or which region, ask them instead of guessing: a wrong region or project is awkward to undo.
Two steps need the user no matter what: approving a sign-in in the browser, and lk agent console,
which is a live voice session for a person. To talk to the agent yourself, use
debugging-livekit-agents.
A voice agent is more than a chat agent with a speaker attached. These constraints drive most design decisions:
Latency. Users expect a reply within a few hundred milliseconds. Context size, tool count, whether a tool call sits on the critical path, and whether responses stream all add to or save from that budget. Plan for network stalls and provider timeouts too; they happen routinely.
Context size. A 10,000-token system prompt with 50 tool definitions feels sluggish on any model, because the model re-reads all of it every turn. Give each phase only the tools it can reach and the instructions it needs.
Listening. Users can't skim or scroll back, and they'll talk over the agent. Long replies are a bug, silence sounds broken, and interruptions are normal.
The usual failure is one agent that does everything. It collects every tool, instruction, and piece of state until it's slow and unreliable, and by that point splitting it is a rewrite.
Handoffs transfer control from one agent to another. Put them at natural conversation boundaries, like greeting → intake → resolution, or general support → billing specialist. Each agent then carries only its own tools and instructions. Choose a boundary where the context can be summarized for the next agent. If the next agent needs everything the previous one had, the boundary is in the wrong place.
Tasks are tightly scoped prompts aimed at one outcome. Use them for discrete operations that don't need a full agent, or where a focused prompt works better than a general one.
If you can't say in one sentence what an agent is responsible for, split it.
The model reads the conversation and proposes actions. Application code owns the records, the permission checks, the state transitions, and every external effect. Most agents that "work in the demo and fail in production" have that line blurred somewhere.
The costliest agent bugs are mutations that did more or less than the caller meant: "no note for him" clearing the whole list, a correction that also reset a confirmed field, a re-stated value that invalidated an approval. Before writing a mutating tool, state its target, what changes, and what must stay the same — then pair it with the nearest request that must do something different.
The rules in short: omission preserves; missing, empty, unknown, and cleared are four different
things; collections get application-issued ids; validate before applying; a scoped negative never
clears a collection; unchanged values are no-ops. When a task requires review before an effect,
approval is a later real user message for that version, delivery is tracked at the speech
boundary, and success is published only after the write commits. The full treatment — including
closing, output ownership, and how text and audio input take different hook paths — is in
references/state-and-effects.md. Read it before building anything that books, edits, confirms, or
ends calls.
Before expanding the tool surface or polishing the persona, pick one ordinary user goal and drive it through the real agent to its required effect — the booking exists, the record changed, the call ended. Write the expected result from the user's request, not from the application's own export. Then pair it with the first guard that must refuse, because a test that rejects everything proves nothing about the guard. Keep that pair green while you add everything else.
Prompt changes break agent behavior as easily as code changes do, and trying it once by hand doesn't count as verification.
debugging-livekit-agents. It runs your agent
locally, lets you send turns as text or speech, and shows the tool calls behind each reply.testing-livekit-agents. At minimum, cover the core
behavior the user asked for, tool invocation with correct arguments if there are tools, and one
failure path.writing-livekit-scenarios
and running-livekit-simulations.If the user asks for no tests, build without them, mention once that you'd recommend them before production, and move on.
reading-livekit-docs.reading-livekit-docsdebugging-livekit-agentstesting-livekit-agentswriting-livekit-scenarios, running-livekit-simulationsreferences/state-and-effects.mdoperating-livekit-agentsWhat SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
7 skills in this plugin
/debugging-livekit-agentsDrives a live multi-turn conversation with a LiveKit agent running locally, using `lk agent debugger`. Use when the user says "test my agent", "try my agent", "does this work", or "why did it call that tool", after editing an agent to check how it behaves, or when an agent on a speech-to-speech model or one that mishears users needs checking. The default for a bare "test"; for regression tests use testing-livekit-agents, for graded runs running-livekit-simulations./operating-livekit-agentsDeploys and operates a LiveKit agent in production: shipping a version to LiveKit Cloud and rolling it back, secrets and configuration, the worker process model and prewarming, safe async inside worker processes, provider timeouts and degradation, graceful shutdown, SDK upgrades, and observability. Use when the user says "deploy my agent", "roll back the deployment", "tail the agent logs", "the first call after a restart is slow", "attached to a different loop / event loop is closed", "prewarm the VAD", "shut down without dropping calls", "upgrade livekit-agents safely", "correlate logs by session", "why is the session transcript empty", "turn on observability", or is changing an agent codebase that is already live. Not for designing the agent (building-livekit-agents) or reproducing one bad conversation locally (debugging-livekit-agents)./reading-livekit-docsLooks up current LiveKit facts (API signatures, CLI flags, config options, model and provider support, SDK changelogs, pricing) from the docs instead of answering from memory. Use whenever a question touches LiveKit specifics: "does LiveKit support X", "what changed in agents 1.8", "what are the arguments to Y", "how much does LiveKit cost", "find an example of Z in the LiveKit repos", or before writing any LiveKit code. Other LiveKit skills load this one first. Covers the LiveKit Docs MCP server and the `lk docs` CLI./running-livekit-simulationsRuns LiveKit agent simulations and acts on the results. Use when the user says "run my simulations", "regression test my agent before deploying", "run the scenarios", "use lk agent simulate", "did my agent pass", "why did this scenario fail", "run simulations in CI", "test the audio pipeline", "check turn-taking and interruptions", or wants to check whole-conversation behavior before shipping. Covers text and audio mode and what each catches, running against a local or deployed agent, degraded-audio flags, automating a pre-release run, and triaging failures with list, view and export. For writing the scenarios use writing-livekit-scenarios. Not the default for a bare "test my agent", which goes to debugging-livekit-agents. Use this skill when the user names simulations, scenarios, a run, CI, or shipping./testing-livekit-agentsWrites turn-level tests for a LiveKit agent in the user's normal test suite: pytest (Python) or Vitest (Node.js). Use when the user asks to "write tests for my agent", "add a test for this tool", "test the handoff", "pin this bug", "why does my agent test fail", or after building or changing agent behavior that needs regression coverage. Covers the SDK's test session harness, assertions on messages, tool calls and handoffs, LLM judging of a reply against an intent, mocking tools, multi-turn tests, and judging whole conversations with the built-in judges. For interactive poking use debugging-livekit-agents. For grading whole conversations at scale use running-livekit-simulations./writing-livekit-scenariosCreates and maintains the scenarios a LiveKit agent simulation runs, and wires the agent to consume them. Use when the user asks "what should I test", "generate simulation scenarios", "write scenarios for my agent", "add a scenario for X", "organize my scenario files", "my simulations are flaky", "the scenario hits my real database", "seed state per scenario", "it passed but booked the wrong thing", "grade the final state", or wants to stress-test a flow before shipping. Covers generating a baseline with the LiveKit scenario generator and refining it, writing the cases generation misses, phrasing simulated-user instructions so they steer reliably, splitting scenarios into sets across files, and the agent-side code that seeds deterministic state from a scenario and fails a run on its final state. To run them use running-livekit-simulations.npx claudepluginhub livekit/agent-skills --plugin livekitOther plugins' skills for the same job