Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

StartOS Packaging — Agent Context

Note

This page is the AGENTS.md that start-cli s9pk init-workspace links into every packaging workspace. Your workspace copy is a symlink to this file, so syncing the guide keeps it current.

You are an AI assistant working in a StartOS packaging workspace. You help create, maintain, and update .s9pk service packages for StartOS. This file is your always-on context: the rules to follow, the patterns to know, and a map of where to read for any given objective. The substance lives in the packaging guide under start-technologies/projects/start-sdk/docs/ — read those pages locally, on demand, as the work requires. Do not load everything at once.

Workspace layout

<workspace>/
├── .startos/              ← workspace marker: build.key.pem (signs your packages) + config.yaml (hosts, registries)
├── AGENTS.md              ← this file (symlink → start-technologies/projects/start-sdk/docs/src/agent-context.md)
├── AGENTS.local.md        ← your workspace-specific notes (never overwritten by a sync)
├── CLAUDE.md              ← loads AGENTS.md + AGENTS.local.md (Claude Code bridge)
├── .claude/skills         ← the packaging skills (symlink → start-technologies/projects/start-sdk/docs/skills), where Claude Code looks
├── .agents/skills         ← the same skills, where Codex looks
├── start-technologies/    ← checkout of the Start9 monorepo on `live-docs` (what is published): the packaging guide, plus the SDK and OS source
└── <id>-startos/ …        ← one or more package repos

Each package repo holds: README.md (what it is / how it differs from upstream), instructions.md (end-user docs shown in StartOS), UPDATING.md (the upstream bump recipe and nothing else), and startos/ (the SDK code).

The workspace root is not a git repository — each package is its own repo, and commits, diffs, and pushes happen inside them. Files at the workspace root (AGENTS.local.md, .startos/, scripts of your own) are untracked; don’t run git status against the root or try to fold a root-level change into a package’s commit.

Keeping the workspace current

The guide, the package template, and this file all live in start-technologies/, so syncing it refreshes everything at once. At the start of every session, fast-forward it against its remote:

git -C start-technologies pull --ff-only

The checkout is on live-docs, the branch that carries what every product has published — never master. That is what keeps the guide, the template, and the SDK source describing the @start9labs/start-sdk a package installs; master carries what hasn’t shipped, where a page can document a call npm cannot resolve. It is also the branch docs.start9.com serves, so the pages on disk are the published ones. Don’t move the checkout to master to see something newer — what is newer there is not what your package builds against.

start-cli is installed outside the workspace, so the sync does not touch it. When an s9pk command warns that yours is behind the published release, update it before going further — the guide on disk describes the newer one.

To track a different source (e.g. a fork), repoint start-technologies’s remote first — the sync follows whatever remote is configured.

Keep workspace-specific notes in AGENTS.local.md; a sync never touches it. That file is for what is true of your setup — your box, your registry, your packages, any departure from the scaffolded layout. Anything that would help every packager belongs in the guide instead: open a PR against start-technologies rather than letting it drift in one workspace.

If start-technologies/ is a symlink to a checkout maintained outside this workspace, skip the sync — its branches are the owner’s to manage, not this workspace’s. Say so rather than pulling it: a development checkout sits on master, so everything read through it is ahead of what packages install. The workspace wants its own (remove the symlink and re-run start-cli s9pk init-workspace).

How to use the guide (local-first)

The guide has two layers:

  • Recipes — intent-driven pages: what to do and which constructs to combine. Start here. Each recipe names the SDK APIs and files involved and links to the reference pages and to real packages.
  • Reference — concept pages documenting each SDK construct in depth with code examples.

Workflow for any objective:

  1. Find the recipe. Open the intent index: start-technologies/projects/start-sdk/docs/src/recipes.md.
  2. Follow its reference links for API details and code examples.
  3. Follow its package links — read the specific files it names in a real package (startos/main.ts, startos/actions/, …) for working production code.
  4. Read only what the objective needs.

Read pages from your local checkout (start-technologies/projects/start-sdk/docs/src/<page>.md). Only if start-technologies/ is missing, fall back to the web (https://docs.start9.com/packaging/<page>.html).

Skills

start-technologies/projects/start-sdk/docs/skills/ holds the packaging skills — each a SKILL.md that drives one whole job end to end, with its own references beside it. They are part of the guide, so a sync updates them like any page. A session opened at the workspace root lists them when .claude/skills (Claude Code) or .agents/skills (Codex) links to that directory, and can then invoke one by name — /package-service <name> in Claude Code, $package-service in Codex. Without the links, open a skill’s SKILL.md at the path below and follow it.

SkillUse when
start-technologies/projects/start-sdk/docs/skills/package-service/SKILL.mdasked to package a new service: it researches the upstream, settles the shape in one round of questions, then scaffolds, builds, verifies on a StartOS box, and hands back

AGENTS.local.md records how this workspace departs from the scaffold — which box to install to, where packages live, how finished work is handed back. Where it and a skill differ, follow AGENTS.local.md.

Where to read for X

NeedRead
Find the right recipe for an objectivestart-technologies/projects/start-sdk/docs/src/recipes.md
How to behave on every change (the disciplines below)start-technologies/projects/start-sdk/docs/src/workflow.md
Branches, release lines, upstream bumps, sibling depsstart-technologies/projects/start-sdk/docs/src/maintaining-a-package.md
File/directory layout of a packagestart-technologies/projects/start-sdk/docs/src/project-structure.md
Service metadata, descriptionsstart-technologies/projects/start-sdk/docs/src/manifest.md
Versions, migrations, release notesstart-technologies/projects/start-sdk/docs/src/versions.md
Daemons, health checks, oneshots, lifecyclestart-technologies/projects/start-sdk/docs/src/main.md
Install / update / restore init logicstart-technologies/projects/start-sdk/docs/src/init.md
Network interfaces and portsstart-technologies/projects/start-sdk/docs/src/interfaces.md
User-facing actionsstart-technologies/projects/start-sdk/docs/src/actions.md
Prompting the user to run actionsstart-technologies/projects/start-sdk/docs/src/tasks.md
Config files as typed modelsstart-technologies/projects/start-sdk/docs/src/file-models.md
Service dependenciesstart-technologies/projects/start-sdk/docs/src/dependencies.md
Build / install commandsstart-technologies/projects/start-sdk/docs/src/makefile.md
Writing the READMEstart-technologies/projects/start-sdk/docs/src/writing-readmes.md
Writing user instructionsstart-technologies/projects/start-sdk/docs/src/writing-instructions.md
Publishing / registriesstart-technologies/projects/start-sdk/docs/src/publishing.md
start-cli referencestart-technologies/projects/start-sdk/docs/src/cli.md

Reading the SDK and OS source (last resort)

start-technologies/ is a checkout of the whole Start9 monorepo, so beyond the guide you already have the SDK source (start-technologies/projects/start-sdk/lib) and the StartOS source (start-technologies/projects/start-os, plus the shared core in start-technologies/shared-libs/) on disk. Nothing to fetch.

Reach for them only when the recipes, reference pages, real packages, and the installed SDK types (node_modules/@start9labs/start-sdk) don’t answer the question — e.g. to confirm exactly what an SDK call does, or how an OS effect behaves. Open one file to settle one question; don’t browse the monorepo to “understand the system.”

If what you find there is a bug, say so. You are standing in a git repo you can open a pull request against — branch from origin/master, not from the live-docs checkout, and switch back to live-docs when you’re done.

Key patterns

Understand these before writing any code (full detail on the pages above):

  • Daemons define the containers that run your service — subcontainer, exec command, ready health check, and a requires array for startup ordering. (main.md)
  • Oneshots run a command to completion before dependent daemons start — file ownership (chown), wallet unlocks, config generation, an app-level schema upgrade. Chained with .addOneshot() alongside .addDaemon() in setupMain(). (recipe-oneshot.md, main.md)
  • Oneshot, init, or migration is decided by what determines when the work runs, not by whether it happens once. A oneshot runs on every start; setupOnInit runs per container init and knows why (kind), and re-runs from the top on every change to anything it .const()s — an init handler is a live reactive context, not a one-shot script; migrations.up runs on a version edge and is the only one that knows which version wrote the data on disk. Relocating or repairing data an older release left behind is a migration — never a guarded oneshot. (main.md § Choosing Between a Oneshot, an Init, and a Migration)
  • Health checks come in two forms: the ready property on every daemon, and standalone .addHealthCheck() calls for ongoing conditions (sync progress, reachability). (main.md)
  • runUntilSuccess spins up a temporary daemon chain during install to bootstrap a service through its own API, then tears it down. (recipe-run-until-success.md)
  • File models are zod-typed representations of config files (JSON, YAML, TOML, …) providing defaults, validation, and reactive reads — the backbone of configuration. Build every shape with z.looseObject at every nesting level — never z.object, which deletes every undeclared key on the next write. The sole exception is a file you have fully modeled and will always keep fully modeled. A FileHelper.env shape is z.object({ … }).catchall(z.string()), which keeps undeclared keys the same way. merge(effects, {}) fills missing fields from their .catch() defaults and repairs invalid ones; it never strips a key you didn’t name. It is not a way to clean or regenerate a config. (file-models.md)
  • Interfaces declare what your service exposes; the user decides where it’s reachable. type ('ui'/'api'/'p2p') is a label, not a control, and Tor is a service the user installs and enables per interface. Never claim a service is on Tor or the public internet. A daemon behind a binding without proxy listens on IPv6 as well as IPv4, never on 0.0.0.0 alone. Every service shares one bridge, so any listener off 127.0.0.1 is reachable by every other service on the server — bound or not, gated by proxy.auth or not: bind internal daemons to loopback, and never export a port that only dependents use. Services opened at the same shared hostname share browser cookies and, with the same scheme, count as same-site: keep the application’s CSRF and Origin checks and HttpOnly session cookies enabled, and never trust another service’s origin merely because it runs on the same server. (interfaces.md, service-to-service.md)

Golden rules

  • Start from intent, not from API. Find the recipe before diving into reference pages.
  • Code lives in reference pages and packages, not recipes. Recipes describe the pattern; reference pages have the API; real packages have production implementations.
  • Match existing patterns — but a neighbouring package is not the authority. Read a package’s code before introducing a new pattern. Then check it against the recipe: the fleet is mid-migration, so the package you happened to grep may itself be non-conformant. “It matches the package next door” is not a quality bar. A recipe and its named reference implementation outrank a package you found by searching.
  • The package repo is not a fork of the application. Take the application from a published image, a git submodule, or a Start9-built image — never by copying upstream’s source in and merging releases into it. Carrying a patch upstream hasn’t taken uses the submodule plus patches/, not a fork. (project-structure.md)
  • The root LICENSE is the wrapped application’s license and nothing else. Replace whatever notice the template or an earlier release carried with upstream’s; don’t keep or append a separate notice for the packaging code. (project-structure.md § LICENSE)

Working discipline (every change)

The full rules are in start-technologies/projects/start-sdk/docs/src/workflow.md; this is the digest.

  • Verify facts; don’t assert from memory. Image names, tags, version numbers, config formats, credential schemes — confirm each with a tool before you rely on it. “I know that X” is a cue to check X, not to write it down. Guessing an image that doesn’t exist or a password format the app rejects fails silently.
  • A comment is not evidence. A comment claiming what an SDK call does — in a package, in a review, in this guide — is a claim to check against the reference page, the installed types, or the SDK source. Don’t accept or repeat it unverified; wrong semantics propagate from package to package.
  • Compiling is not working. A green tsc and a clean s9pk pack prove the code builds, not that the service runs. Before reporting a feature done, exercise it against a running service (install, log in, write data, restart). To look inside one, start-cli package attach <id> -n <subcontainer-name> -- <cmd> — -n takes the subcontainer’s name, while -s takes its internal Guid and fails on a name (workflow.md). State what you verified and what you didn’t — never imply a feature works when you only compiled it.
  • Don’t fabricate; verify or flag. Never ship an invented icon/logo, a config format you didn’t confirm, or placeholder facts in the README. Fetch the real thing, or leave it and say plainly that the gap is still there.
  • Fix what you find; file only what needs deciding. A defect you spot with the package already open is a fix in the branch you are on, related to your task or not — you have the context to be sure and the next person won’t. File a GitHub issue on the package repo when the call isn’t yours: cause unpinned, two defensible fixes, or too large to ride along. Never both — the issue or the PR body, not the finding written out twice. Going the other way, an open issue is a report, not a queue: implement one when asked or when it is labelled Approved, then Closes #<n>. Don’t create a TODO.md/NOTES.md/PLAN.md in place of any of this — a notes file is invisible to whoever can act on it and stale the moment the session ends. (workflow.md)
  • Search before declaring impossible. Before working around a limitation, grep the SDK types (node_modules/@start9labs/start-sdk/**/*.d.ts) and existing packages. “The SDK can’t do X” is a claim to verify in the types, not a conclusion from the docs (this is how runAsInit is found).
  • Refer to a multi-flavor dependency generically. In user-facing text bitcoind is Bitcoin — never Bitcoin Core or Bitcoin Knots. (dependencies.md)
  • Keep README.md and instructions.md in sync. README.md is the package’s technical reference — how it works, what its actions do, how to diagnose it — and the only technical file an AI support or administering agent reads; instructions.md is the user’s guide to the service as it is now — never a record of what changed, which belongs in releaseNotes. Update each in the same change as the code that makes it wrong. Content rules: writing-readmes.md, writing-instructions.md.
  • A package’s AGENTS.md restates nothing README.md or instructions.md says. Its one reader has both, so it carries only what has no home in them: repo mechanics, a change that looks right and is not (the imperative plus the one clause that says why), extension points, naming traps, and build or test invocations particular to the repo. A fact the README already states does not become a rule by being repeated here. Most packages need one to four bullets; a simple one needs none. (project-structure.md § AGENTS.md and CLAUDE.md)
  • Iterate with a dirty tree; commit once. The -modified pack-hash suffix is informational — don’t commit between test attempts. One clean commit when the package works; git reset --soft HEAD~N collapses accumulated fixups.
  • Squash a feature branch’s PR; give a long-lived branch’s PR a merge commit. next, a release line and a sync-next/<base> branch take gh pr merge --merge, or the next sync conflicts with commits the base already holds in squashed form. (maintaining-a-package.md § Merge a long-lived branch with a merge commit, never a squash)
  • Bump to the latest SDK before opening a PR. Check npm view @start9labs/start-sdk version against the pin; if newer, bump and re-verify before you push. (publishing.md § Pre-Publish Checklist, maintaining-a-package.md § Bumping the SDK)
  • Name your model in every PR body, on a line of its own: model: <model id>, the exact ID your harness reports (model: claude-opus-5-5). List every model that wrote part of the change, comma-separated. Start9 picks the AI reviewer from it, so update the line when a later push comes from a different model. (publishing.md § The Pipeline)
  • Pre-existing errors are still errors. A red tsc, test, or pack step means the package doesn’t pass, even if unrelated to your change. Fix it or flag it; never report green when a check was red.
  • Don’t create unnecessary version files. The latest version always lives in startos/versions/current.ts; most bumps just edit that file in place. A new file is spun off only when the version already in current.ts carries a migration, meaning an up whose body does work (the template’s empty up with down: IMPOSSIBLE carries none). That migration stays with the version that introduced it and is never carried forward into a successor, idempotent or not, while a version having been released is not a reason to declare it. VersionGraph synthesizes a range vertex beneath current, so any lower installed version migrates up in one hop without its own node; canMigrateFrom is derived from that graph, not authored. See versions.md (When to Create a New Version File, Why Released Versions Don’t Need to Be Declared, Release Notes).
  • Constants and helpers go in startos/utils.ts, not a file of their own. A new top-level startos/ file is warranted only for a large, self-contained unit, never for a single function or constant. A package repo also carries no CHANGELOG.md — release notes live in releaseNotes — and no test suite of its own. (project-structure.md)

Starting a new package

Scaffold first — run start-cli s9pk init-package "<Name>". Do not hand-assemble a package by copying files out of another one. Scaffolding produces a barebones hello-world clone. Then work new-package-checklist.md top to bottom — it takes the package from clone to release-ready (descriptions, image, icon, interfaces, daemons, docs, first build, install-and-verify). The checklist is a guide page, not a file in the package: read it, don’t copy it in. Wrapping an existing upstream Docker image? Read recipe-prebuilt-image.md first. Asked to package a named project end to end? That is the package-service skill (see Skills): it does the upstream research and the install-and-verify pass around this sequence.