# Guides

A guide is what people also call a skill, Anleitung or
instructivo: instructions an agent follows, with optional files. The agent of
the person who uses it runs it, never Adlass; work Adlass runs is a routine
(read_docs("routines")). Each guide belongs to one Space. Never write a guide
as a document.

Create or update a guide in one call: `guides.push` with `space_id`, `name`,
`summary` and `instructions` as text. A local SKILL.md folder is optional:
`files` carries further files (text, by path), `requires` the local tools the
guide needs, such as `[{"tool": "python3", "min": "3.11"}]`. An existing
`slug` is updated wherever it lives. The result is the active version and its
`content_hash`; a push without changes creates no version.

- `guides.list` with `space_id` lists the published guides of a Space with
  their stubs; `guides.search` lists every guide, drafts included.
- `guides.load` returns instructions, the file list (path, size, sha256),
  `requires` and `content_hash`; `guides.file` returns one file in pages.
- To change a guide: `guides.load`, change, `guides.push` with the
  `expected_content_hash` of that load. A working copy someone is editing in
  the app blocks the push (`draft_in_progress`).
- `guides.draft.create` and `guides.save` serve the editor in the app (draft,
  autosave); agents use `guides.push`. `guides.rename`, `guides.versions`,
  `guides.restore`, `guides.delete` and the `guides.share*` operations work
  like their routine counterparts.

## Guides in local agents

A guide works for a local agent (Claude Code, Codex and other agents that
read SKILL.md folders) like a local skill: it is listed with its summary, the
agent loads it when the summary fits the task, and it is current on every
start.

- With the adlass CLI, a person runs `adlass guide install --space <space_id>`
  once. Every guide of that Space lands in the agent's skills folder
  (`~/.claude/skills/<slug>/`, `~/.agents/skills/<slug>/`): a short SKILL.md
  with the summary as description, the instructions in
  `.adlass-instructions.md` and the files next to them. Each SKILL.md runs
  `adlass guide sync <slug>` before the agent reads the instructions; that
  sync updates the guide and brings the whole Space in line: new guides are
  added, deleted ones removed. `adlass guide install <slug>` installs one guide.
- Without the CLI the local folder holds `stubs.skill` as SKILL.md (from
  `guides.list`). The agent calls `guides.load` and follows `instructions`. For
  the files it calls `guides.bundle` and runs the returned `command` in a
  shell: it writes SKILL.md and every file of the version into the folder
  without passing them through the agent (the token goes as a header, works for
  one download within 5 minutes, carries the caller's access and is never shown
  or stored). To check for a newer version it calls `guides.load` with
  `if_none_match` set to the last `content_hash`; `unchanged: true` means
  nothing to do and is not counted as a use.

A change reaches everyone at their next start of the guide.

Scripts need a person to publish them: a version that adds or changes a file
other than .md, .txt or .csv, a file under `scripts/` or starting with `#!`,
or the frontmatter of the instructions fails in `guides.push` and
`guides.save` with `guide_scripts_need_approval` (`details.paths`). A person
pushes it with `guides.push_scripts` (Public API with an API key, or the
web app); agents and the adlass CLI cannot. Markdown-only changes go through as
before. Once published, everyone in the organization who may use the guide
runs its scripts; no further approval per person. A guide with scripts is not
served to anyone outside its organization (guests of the Space, templates:
`guide_scripts_foreign`, 403): install it into your own organization, where a
person publishes it.

`guides.install_plan(slug)` lists what a person needs before the first
run: the grants and connections the guide names by id and whether the caller
may use them (`usable`, `grant_id`), `requires`, `ready` and the adlass
commands (`adlass login`, `adlass guide install <slug>`).

## Writing a guide

Read this before the first `guides.push`.

- One guide is one task the team repeats (answer the chats, create a product,
  close the month). Several tasks are several guides.
- `summary` decides when an agent loads the guide: it is the only text a local
  agent sees beforehand, and Space rules hand it to agents under `references`.
  Say what the guide does and when to use it, with the words people use when
  they ask for it; agents read up to 300 characters.
- The instructions stay short: the steps as numbered lines, the fixed rules,
  and a table "file → when to read it". Everything only one step needs goes
  into its own file, one file per topic; the agent reads it when it gets there.
- Data comes from the systems at the moment it is needed (operations, records,
  documents), never from files of the guide. No passwords, tokens or personal
  data in instructions or files. IDs only when the whole team shares them;
  `guides.install_plan` checks the grants a guide names.
- What applies to several guides belongs in the Space rules (`spaces.context`),
  which name each guide as `@slug` and each table as `#key`. Conventions for one
  provider belong in the connection rules (`integrations.context`). A guide
  repeats neither.
- A guide never writes outside its own folder and never into CLAUDE.md,
  AGENTS.md, agent settings or hooks.
- Scripts only where a step cannot be done with operations; every script needs
  a person (see above).
- `audience`: `AGENT` (default) for agents, short, naming guides, operations,
  tables and files directly. `TEAM` for people in the team, full sentences
  under headings, terms explained, no operation keys or field names in the
  running text, technical detail in files. Agents load both.

## Errors and fixes

- `guide_scripts_need_approval` (403) from `guides.push` or `guides.save`: the
  version changes scripts (see Guides in local agents). Ask a person to push it
  with `guides.push_scripts`; push markdown changes alone.
- `guide_scripts_foreign` (403): a guide with scripts from another
  organization. Install it into your own organization, where a person
  publishes it.
- `guide_not_found`: the slug or id names no guide you can see; a routine's id
  also reads as missing here. `guides.search` or `guides.list` give the ids.
- `guide_not_runnable` from `routines.runs.start`: a guide is followed by an
  agent, not started as a run. Load it with `guides.load`.
- `slug_taken_by_routine` (409): a routine already uses the slug. Push with
  another `slug`.
- `content_hash_conflict` (409): the guide changed since your load
  (`details.current`). Load it again, apply your change, push again.
- `draft_in_progress` (409): someone edits the guide in the app. They save or
  discard that working copy first.
