Writing a pack
A pack is the content of one department: role templates, SOPs and skills, as data. Adding a pack never means changing the core. This guide covers the layout, the three kinds of file, the limits the loader enforces, and the tests. The packs README is the reference. The contributor skills nexus-add-department and nexus-skill-authoring hold the checklists, and the add-a-department runbook walks the whole change.
nexus has had no external security review. Pack tests use scripted executors and no model. They show the machinery works and the data is consistent. They say nothing about how well a model follows your skill.
What a pack changes today
A pack’s role templates and SOP stage instructions reach the model. Its skills do not yet. They install in quarantine, with no tools and no network, and nothing loads a skill body into a run (HV-124). A pack can only make the loop stricter. It has no way to widen anyone’s hands. The Marketing pack’s schedule is the only one that ships.
Layout
packs/<id>/
pack.json id, department, version, license, description, and the full lists
roles/<role-id>.json a role template
sops/<sop-id>.json a SOP definition
skills/<name>/SKILL.md a skill (plus any files it needs)
README.md what the pack does, its guardrails, the tools it assumes
pack.json must list every role, SOP and skill. The loader refuses anything it does not list and any listed file that is missing. The pack id must equal its folder name. The data pack is a small worked example. This is its pack.json with the description shortened:
{
"id": "data",
"department": "data",
"version": "0.1.0",
"license": "MIT",
"description": "...",
"roles": ["data-analyst"],
"sops": ["analytics-report", "data-quality-review"],
"skills": ["analytics-report", "data-quality-check"]
}
Role templates
A role template is a wish list. It has an id, title, department, team, description, defaultSkills, defaultGrants and defaultTier (always teacher). A grant is a tool pattern plus action classes, for example { "tool": "fs.read", "classes": ["read"] }.
HR intersects the grants with the department ceiling when it hires. The loader goes further and refuses a template that asks for more, so what the file says is what an employee gets. It also refuses:
- the catch-all
*and a bad tool pattern; - a tool whose name says it decides for you or vaultd: approve, sign, override, grant, widen, hire, retire, secret, token or receipt;
- a role in another department, a team the department does not have, a tier above
teacher, and a default skill that is not in the pack.
The role id must be in the department’s roster in packages/org/src/departments.ts, or HR cannot hire it. A test fails if it is not.
Hands ceiling and reserved classes
A department’s ceiling is the most any employee in it can hold. Ceilings and guardrails live in departments.ts, not in packs. A pack cannot change one. Start from the narrowest grants that let the role work.
Six action classes are reserved: money, trading, credential, cloud-resource, publish and irreversible. A reserved class may sit in a ceiling only if the department lists it in approvalRequired. Today three do: Software Development and Operations for cloud-resource, and Marketing for publish. Even then the ceiling only makes the action possible. Every use needs a card you approve and a single-use receipt, and a tainted run loses it.
If a role template holds a reserved class, add its tool to RESERVED_ALLOWED in packages/packs/test/packs.test.ts with the guardrail that allows it. Never put approval, signing or credential rotation in a role.
SOPs
A SOP says how a department’s teams run the fixed loop for some task types. The loop is brief, plan, build, verify, review, deliver, retro. A SOP can only add to it. This is a trimmed version of the data pack’s analytics-report:
{
"id": "analytics-report",
"title": "Analytics report",
"version": "0.1.0",
"department": "data",
"taskTypes": ["*", "data.analysis"],
"stages": {
"build": {
"instructions": "Aggregates only: no row-level records.",
"roles": ["data-analyst"],
"requires": [["report"]]
},
"verify": { "requires": [["test-run"]] }
},
"maxFixRounds": 3
}
taskTypesare*(the department default) or<department>.<task>in the SOP’s own department. Two SOPs may not claim one task type.- A stage may add
instructions(appended to the built-in text, up to 2000 characters),rolesto try first, andrequires. Each inner list inrequiresis one requirement met by any one of its evidence kinds: test-run, diff, report, citation, scan, approval or log. Every requirement must be met. maxFixRoundsruns from 0 to 3. A pack can lower the limit and never raise it.scheduleis optional:every 6hordaily 09:00 UTC. It opens one ticket per slot under a charter you bind withnexus schedule enable. It starts nothing by itself.
The loader refuses a SOP that asks for evidence no hands in the department can produce, a stage role outside the department roster and a task type outside the department.
Skills
A skill is a folder with a SKILL.md: YAML front matter, then a markdown body. See the skills README for the whole pipeline.
---
name: analytics-report
description: Answer a business question with aggregate numbers. Use when a ticket asks for metrics. Read-only.
version: 0.1.0
license: MIT
requires:
tools: [fs.read, data.query]
hosts: []
classes: [read]
task-types:
- data.analysis
---
nameis lower case letters, digits and single hyphens, at most 64 characters, and equals the folder name.descriptionis 1 to 1024 characters. Say what the skill does and when to use it. The router picks skills by this text.licenseis an SPDX id on the permissive allowlist. A skill without one is refused. Imported material needs anoriginrecord. See the license and reuse policy.requiresnames the tools, hosts and classes the skill needs. It can only narrow. Declare every host you contact, and ask for the minimum. A network tool without hosts is refused.task-typesare<department>.<task>names in the pack’s department.
Write the body as short, imperative steps. Say what the skill must not do and when to stop and ask. Never tell the agent to skip approval, claim a human approved, ignore earlier instructions or hide output. Never put a secret in a skill. Refer to credentials by handle. Put long reference text in separate files, because the body loads on demand.
Signed skills use the strict codec, so an unknown front-matter key is an error. Imports into quarantine use a lenient one that drops unknown keys with a warning.
What the scanner flags
The scanner reads every file as data and never runs anything. It has 19 rules:
- remote-exec, dynamic-eval, process-spawn, obfuscation and encoded-blob;
- credential-read, env-dump, exfiltration and undeclared-host;
- bidi-control, hidden-unicode, prompt-injection and approval-bypass;
- undeclared-reserved-action, write-outside-workspace, persistence and unattended-loop;
- binary-file and executable-binary.
The level decides what a finding means. Quarantine never blocks. Personal blocks at critical. Team and above block at high. There is no waiver. Reword the text or ask for a review. The scanner is a set of text patterns, not a sandbox. A hostile skill can be reworded past it, which is why quarantine gives no tools whatever the scan says.
Quarantine and signing
installPacks puts every skill in quarantine unless you pass a level. A quarantined skill has an empty grant layer: no tools and no network. Pack skills ship unsigned, because the signing key is held by the security lead on hardware and never by an agent. At team level and above the registry refuses an unsigned skill, and nothing from the pack is registered. A skill whose bytes changed since the loader read it is refused too.
The content hash covers every file in the skill folder, so adding or editing any file changes the hash and voids the signature. There is no nexus command to sign or promote a skill yet. Do not try to sign from a script.
Tests
The generic tests pick a new pack up on their own. They check that every pack loads, every skill has no scanner finding, every grant is inside the ceiling, every SOP’s gates can be met, and every shipped SOP runs through the real engine from brief to retro. Add tests for your department’s own guardrails next to them.
npm run typecheck -- packs
npx vitest run packages/packs
npx eslint packages/packs && npx prettier --check packages/packs
npm run check:license
Use scripted providers and fake clocks. No test may use the network. To see what a pack adds, run nexus packs list, from the built bundle or from source:
npm run build && node dist/nexus.mjs packs list
node --import tsx packages/cli/src/main.ts packs list
A pack the loader refuses stops run, packs list and schedule with its own message, before vaultd is asked anything. The build copies the packs to dist/packs, and dist/nexus.mjs reads them from there; a nexus.mjs copied away on its own has no packs folder beside it, so it cannot list packs.