Using Lemano from a coding agent
A coding agent can run lemano for you: read your servers, tell you what
changed and why, compare them with your Ansible playbooks, and prepare a
revert for you to approve. The Lemano agent skill gives the agent the
commands, the JSON fields, the exit codes and the rules it should follow.
It is a set of Markdown files that any agent supporting the
Agent Skills format can load. It does not
install Lemano: install lemano first (see the
README).
The skill is in skills/lemano, under the Apache
License 2.0 so that you can copy it into your own projects.
Install the skill
Pick one. Each installs the same files.
| Agent | Command |
|---|---|
Many agents (npx skills add lists the ones it supports) | npx skills add opafra/lemano |
Any agent gh skill supports | gh skill install opafra/lemano lemano |
| Claude Code, as a plugin | claude plugin marketplace add opafra/lemano, then claude plugin install lemano@lemano |
| Codex, as a plugin | codex plugin marketplace add opafra/lemano, then install lemano from it |
| By hand | copy the skills/lemano folder into the skills folder your agent documents (the project’s or your own) |
npx skills add asks which agents to install for and whether to install
for the project or for you (-g); add -a claude-code to name an agent
and -s lemano to name the skill. gh skill install takes --agent and
--scope user or --scope project. Skills installed for a project are
shared with everyone who works in it.
Review the files before you rely on them: a skill is instructions your agent follows with your permissions.
Give your agent the setup prompt
Paste this into your agent. It makes the agent check that Lemano works, learn the rules, and take one read-only look at one server before it does anything else.
Lemano is installed on this machine. Use the lemano skill to work with it.
If the skill is not installed, tell me how to install it
(npx skills add opafra/lemano) and stop.
Rules, which apply to every command:
- Show me each lemano command before you run it, and say what it
writes: on a server (only "lemano revert" and ending its trial), in the
local store (discover and other passes), in a local file (--out,
--write, export), or nothing.
- Run "lemano revert" with --dry-run first,
show me the whole plan, and run it for real only after I say yes to that
plan, with the command it gives (--expect-plan DIGEST). If it fails with
exit code 9 and a new plan, show me the new plan and ask again. Use
--auto-approve only if I ask for it, and never --auto-confirm or
--no-trial before I have said yes to the exact plan.
- Never use --show-secrets, never print the store's key file or
LEMANO_PASSPHRASE, and never change a pinned host key. If a host key is
unknown or changed, show me the fingerprint and wait. Use
--accept-new-host-key only after I tell you I checked it against the
server.
- Use -o json when you parse output. Report what the output says and what
it does not cover (kinds not read, blind windows); do not say a server
is fine.
First steps:
1. Run "lemano version" and "lemano target list -o json" and tell me what
the store knows.
2. Ask me which one server to look at. Run "lemano discover NAME -o json"
on that server only, and summarise the result and any error.
3. Run "lemano summary -o json" and tell me what needs attention.Questions to ask
Once the skill is in place, these work as they are, or with your server and file names:
- “What changed on my servers this week?” The agent runs
lemano summary --since 168h -o jsonand reads the groups and attributions. - “Why did
/etc/ssh/sshd_configchange on web-01?” It finds the generation withlemano history web-01, readslemano difffor that file, and quotes the attribution, including when the cause is unknown. - “Which packages were installed by hand on db-02 since the last
baseline?” It uses
lemano diff db-02 --baselineandlemano state list db-02 --kind Package. - “Which parts of web-01 are not in my playbooks?” It runs
lemano ansible check site.yml -i inventory --limit web-01and reads the forgotten objects and the coverage, naming the playbooks the scope covers. - “Propose the changes to my roles that match what is on web-01.” It runs
lemano ansible codifywith--outso that nothing is written until you have read the patch. - “Put
/etc/hostson web-01 back to how it was in generation 12.” It shows the plan fromlemano revert web-01 --to 12 /etc/hosts --dry-run, asks, and runs the revert only after your yes.
What the skill makes the agent do and not do
The skill is a set of instructions, not a sandbox: your agent’s own permission prompts still decide what it may run. The skill asks the agent to:
- say what each command writes: only
revert(and ending a revert’s trial) writes on a server;discoverand the other passes record generations in the local store;summary --out,ansible codify --outor--write,ansible exportandansible import --outwrite local files;history,diff,target list,target show,state,verifyandsummaryonly read; - show the full revert plan and wait for a clear yes before it writes;
- leave host keys, machine identities, locks and baselines to you;
- keep secrets out of its output and its commands.
Keep your agent’s confirmation prompt on for lemano revert, and for the
commands that change a pin or a lock (lemano target rekey, lemano target confirm-identity, lemano unlock), so that the decision is yours even if
an instruction is missed.
A lemano revert without --expect-plan, --auto-approve or --dry-run,
run without a terminal or with -o json, prints the plan, writes nothing
and exits with code 9 and the reason ConfirmationRequired; the error on
the last line of standard error has a hint with the exact command that
approves it: yours plus --expect-plan and the digest of the plan shown
(and, when the revert runs as a trial, a note that --auto-confirm or
--no-trial is needed without a terminal). That command reads the server
again and applies the plan only if it is unchanged; when the host changed
what the revert touches, it writes nothing, prints the new plan and fails
again with code 9, and you show the new plan and ask again. --auto-approve
accepts whatever plan the run builds: leave it to scripts, or to the
person’s explicit request. The same goes for an unpinned
host key of lemano ansible discover, check, codify and export: the
command is refused with exit 4, the fingerprint is in the error, and
--accept-new-host-key in the hint is yours to give after you have checked
it. See running Lemano from scripts and agents, the
exit codes and the
revert reference.