# The contract examples (https://docs.neuralisapp.com/package-system/reference-package)

The package contract has three example packages, one for each way a package
[reaches the platform](https://docs.neuralisapp.com/package-system.md#four-ways-a-package-reaches-the-platform)
(a package folder listed on a source loads like the project drop). Each
exercises every surface its install class can carry, once, and nothing it
cannot: what this site describes, the examples declare.

## Three examples, one per install class [#three-examples-one-per-install-class]

| Example | Install class | Package identity | Runtime |
| --- | --- | --- | --- |
| `example-builtin` | Admin-installed npm/dependency package | `@neuralis/example-builtin` | Node, in-process, host-assigned native trust |
| `example-project` | A drop into a project's `_packages/` directory | `@example/project-package` | Extism WASM sandbox, untrusted |
| `example-source` | Markdown discovered in a [synced source](https://docs.neuralisapp.com/package-system/source-packages.md) | `@neuralis-examples/example-source` | None — no install step, no code, no `package.json` at all |

<Callout type="warn" title="Schema demonstrations, not working capabilities">
Each contribution file teaches its category's schema: which fields exist,
which are required, what the host does with each, what breaks if wrong. None
ships a useful skill, rule or agent — one competing with the platform's real
ones would pollute every agent's context. Copy the *shapes*; the examples
themselves do nothing.
</Callout>

## Where to get them [#where-to-get-them]

Native package source is not published; the examples reach you through the
**package registry** ([marketplace](https://docs.neuralisapp.com/package-system/marketplace.md)), the one
rail serving a *single element* rather than a whole tree.

<Callout type="warn" title="Public registry not yet deployed">
`registry.neuralisapp.com` does not resolve to a public registry today, so
there is no public URL to install from yet. A self-hosted instance serves the
full API and the CLI now — point `NEURALWEB_REGISTRY` at it.
</Callout>

Markdown elements (Tier A) read as plain text; schema-only contracts (Tier B)
as one self-verifying JSON envelope; runtime-bound elements (Tier C) answer
`409 TIER_C_NOT_STANDALONE` with a link to the parent package. The tier
membership and endpoints are on the [marketplace page](https://docs.neuralisapp.com/package-system/marketplace.md).

```bash
# Tier A — the authoring walk-through, plain text (no version = latest listed;
# drop the --line-* range for the whole file)
neuralweb read '@neuralis/example-builtin#docs/docs.create-package' --line-start 1 --line-end 40
# Tier B — a tool schema, verbatim, in a self-verifying JSON envelope
neuralweb info '@neuralis/example-builtin#tool/example_query'
```

Every read is verified end to end (one mismatched byte fails).
`neuralweb install <ref> --channel project` drops a verified Tier-A element into
a project's `_packages/`; `--channel builtin` only **prints** the admin's
command — installing builtin-class code is the admin's trust act. There is no
base package to fork: author your own `@yourco/*` against the same contract.

## What each tree demonstrates [#what-each-tree-demonstrates]

### `example-builtin` — the full contract [#example-builtin--the-full-contract]

The builtin class is the only one that carries every surface, so this tree is
the reference for all of them.

```text
package.json                    # the manifest — the `neuralis` key holds everything
README.md                       # package-meta — NOT a contribution
hooks.json                      # declarative lifecycle hooks
tools/example_query.json        # strict JSON Schema + one x-neuralis extension
tools/example_health.json
workflows/sample-workflow.json  # a workflow TEMPLATE — typed JSON, never prompt-injected
skills/example-skill/SKILL.md   # agentskills.io-shaped skill (category: skill)
rules/guardrails.md             # safety rules (category: rule)
agents/example-agent.md         # a delegation target (category: agent)
docs/create-package.md          # authoring walk-through (category: docs)
team/example-member/member.json # a team member + its identity prose
team/example-member/identity/persona.md
src/lifecycle.ts                # init / start / stop / api + hook callbacks
src/routes/health.ts            # file-discovered HTTP routes
src/routes/query.ts
src/tools/example_query.ts      # handler paired with tools/example_query.json (default-exported)
src/tools/example_health.ts
app/surfaces/{kind}/{id}/       # one canonical root per asset-backed surface
app/shared/example-theme.css    # package-public assets — bundle-mode surfaces only
assets/example-icon.svg         # static icons, images
```

- **Manifest.** Identity and model-facing description, the
  `source`/`runtime`/`access`/`meta` blocks, `requires` (two features with
  default role grants and an `accessFeature` base gate), `credentials[]`, a
  `sources[]` instance, `configSettings[]`, `uriPolicies`, `policies[]`,
  `connectors[]`, `resources[]` and `app.surfaces[]` —
  [Manifest](https://docs.neuralisapp.com/package-system/manifest.md).
- **Tools.** `example_query` and `example_health` show the strict schema —
  `$schema`, `title`, root `additionalProperties: false`, one `x-neuralis`
  extension (dotted `operation`, `transport`, full `annotations` with the
  mandatory risk `category`, a card `ui` block). Each handler at
  `src/tools/<name>.ts` binds by its **default export**; a named-only export is
  silently skipped — [Tools](https://docs.neuralisapp.com/package-system/tools.md).
- **Markdown contributions.** A folder-per-skill `SKILL.md`, a rules file, a
  delegation agent, a docs walk-through and a `team/` member with identity
  prose, each categorized by its folder. Root loose markdown (the README) is
  package-meta, never a contribution — [Skills](https://docs.neuralisapp.com/package-system/skills.md).
- **Workflow template.** `workflows/*.json` is a typed JSON array like `tools`,
  not a sixth file category: inputs, `manual` + `webhook` + `schedule` triggers
  with `maxRuns`/`endAt` guardrails, delivery, an execution policy, a feature gate.
- **Lifecycle and routes.** `src/lifecycle.ts` exports `init`/`start`/`stop`
  and a typed `api()`; `src/routes/*.ts` are file-discovered, feature-gated
  handlers — [Lifecycle](https://docs.neuralisapp.com/package-system/lifecycle.md), [Routes](https://docs.neuralisapp.com/package-system/routes.md).
- **Hooks.** `hooks.json` declares `PreToolUse`/`PostToolUse` hooks on named
  tools whose `callback`s are named exports of the lifecycle module.
- **URI policies.** Baselines for `data://<self>/**` and `packages://<self>/**`,
  with a nested rule keeping `src/**` read-only —
  [URI policies](https://docs.neuralisapp.com/package-system/uri-policies.md).
- **App surfaces.** Two widgets, one standalone dock entry, two tool-matched
  cards. The first widget and card are self-contained HTML (the default); the
  second card, `example_approval.card`, matches the same tool with
  `"state": "approval-required"`; the second widget declares
  `"assetMode": "bundle"` (stylesheet, scripts, a JSON sibling, an image, the
  package-public `app/shared/example-theme.css`) and opts out of a dock entry
  with `"dock": {"show": false}` — [App surfaces](https://docs.neuralisapp.com/package-system/app-surfaces.md).
- **Connectors, resources, policies.** An in-process host gateway connector, an
  OAuth-configured HTTP gateway, an MCP resource entry and full policy shapes.
  `policies[]` kinds `safety` (tool blocklist, per-tool timeout), `permission`
  (tool allowlist) and `trust` (input validation on/off) run before any handler,
  and a deny is absolute; `kind: "access"` is accepted and does nothing (tool
  gating is only `x-neuralis.requires.features`). `safety` spans every loaded
  package, so it is honoured only from a native manifest; `permission` and `trust` restrict
  the declaring package at any trust level.

No example ships a `commands/` folder: the array remains for imported packages;
new packages ship skills.

### `example-project` — the sandboxed project drop [#example-project--the-sandboxed-project-drop]

The same contract, narrowed to a `_packages/` drop: one tool with its handler,
one route, one skill, one rule, one docs file, and **one iframe widget with its
dock entry** — an untrusted package has exactly one renderer. A single feature
id gates every surface it contributes (tool, route, widget, dock entry,
feature-gated markdown), so one grant is visibly several enforcement points.
Two things it deliberately does *not* do are covered on
[WASM build](https://docs.neuralisapp.com/package-system/wasm-build.md).

### `example-source` — markdown only, no manifest [#example-source--markdown-only-no-manifest]

No `package.json`, no code, no install step: the folder layout is the
declaration. It ships `skills/`, `rules/`, `instructions/`, `docs/` and a root
`AGENTS.md`, and shows the default-ON / opt-in split of
[source packages](https://docs.neuralisapp.com/package-system/source-packages.md).

## Deliberately never loadable [#deliberately-never-loadable]

The examples pass every validator yet never auto-load. Three independent gates:

- Neither is **a dependency of the host**, and builtin discovery iterates only
  the host's own dependencies.
- Both manifests carry `neuralis.referenceOnly: true`, a separate exclusion in
  the same loop. (`example-source` has no manifest — it is markdown in a source,
  which contributes no code by construction.)
- Their ids sit in the host's explicit reference-only set, so a manifest that
  *lost* its flag still could not be promoted: the exclusion runs **before**
  native trust assignment.

No gate relies on an invalid manifest. Any documentation-only package opts out
the same way:

```json
{ "neuralis": { "referenceOnly": true } }
```

A dependency carrying the flag never auto-loads. The examples' tools, skills
and routes are **authoring examples, not a callable or smoke-test surface**.

## What this costs an agent [#what-this-costs-an-agent]

Rules and instructions enter every system prompt, agents are read when a
delegation resolves, skills cost only their description until activated, docs
are read on demand. So the example skill declares `invocation: manual`, the
agent is feature-gated, and the long walk-through costs nothing until opened —
copy that discipline with the shape.

## Reading order for new authors [#reading-order-for-new-authors]

1. Skim `example-builtin`'s `package.json` top to bottom with the
   [manifest reference](https://docs.neuralisapp.com/package-system/manifest.md) open.
2. Read `tools/example_query.json` next to
   [Tools](https://docs.neuralisapp.com/package-system/tools.md) — the schema rules are where most
   first packages fail validation.
3. Read `skills/example-skill/SKILL.md` and
   [Skills](https://docs.neuralisapp.com/package-system/skills.md) for the activation model.
4. Read the example matching how *your* package reaches the platform, and
   validate early: [Testing and validation](https://docs.neuralisapp.com/package-system/testing.md) runs the
   same checks your package meets at bootstrap.