> ## Documentation Index
> Fetch the complete documentation index at: https://docs.nika.sh/llms.txt
> Use this file to discover all available pages before exploring further.

# Project setup

> Give workflows, binary resolution, traces and application code an explicit boundary.

> [!TIP]
>
> **One client, local by default.** Import `Nika` from
> the package root and omit `url`. The client takes the engine
> from `bin`, then `NIKA_BIN` (both absolute paths), then
> the platform package npm installed with it; it never uses a
> `nika` found on your `PATH`. These examples target
> the published [0.124.4 SDK release](https://github.com/supernovae-st/nika-client/tree/v0.124.4).

> [!NOTE]
>
> **Live project control plane.** The released engine
> discovers `nika.yaml` from the working directory toward its
> ancestors. The file is optional when built-in defaults are enough. Its
> project-shape grammar is closed: `nika` ·
> `ceiling` · `arm` · `traces` ·
> `registry`. Direct runs and the cadence path
> (`nika arm` · `nika serve`) read the same file.

The SDK should make the project boundary visible, not dissolve it into
application objects. The root `nika.yaml` is the control plane — optional
for a first workflow, required once the project arms beats or sets policy.
Each `*.nika` file is executable workflow intent.

## Recommended layout

PROJECT TREE · CONTROL PLANE + INTENT + PROOF

<pre tabIndex="0">
  project/
  &#x20;   ├── nika.yaml                  # project profile + optional armed beats
  &#x20;   ├── workflows/
  &#x20;   │   ├── daily-brief.nika  # workflow intent
  &#x20;   │   └── release.nika
  &#x20;   ├── src/
  &#x20;   │   ├── nika.ts                # Nika construction
  &#x20;   │   └── release.ts             # product code
  &#x20;   ├── .nika/
  &#x20;   │   ├── traces/                # run journals
  &#x20;   │   └── arm/                   # firing ledgers + watermarks
  &#x20;   ├── package.json
  &#x20;   └── .gitignore
</pre>

* `nika.yaml` governs project-wide spend and the released reader profile this
  project uses.
* `workflows/` is reviewed as intent.
* `src/nika.ts` owns binary resolution and the working directory, not a
  second copy of project policy.
* `.nika/` is runtime state: run records, firing ledgers, server job state
  and, when you serve over HTTP, the server's bearer token. Ignore it in
  source control and mount it deliberately on a server.

## Found the project

A project file is one line: the project's kebab-case name. Create it and let
the engine read it back:

```sh theme={"system"}
printf 'nika: my-project\n' > nika.yaml
./node_modules/.bin/nika arm
```

```text theme={"system"}
nothing armed — /path/to/project/nika.yaml carries no `arm:` entry
```

`nika arm` reads and validates the project file and its cadences, reports
what is armed, and schedules nothing. Add policy as you need it, for example a
default spending ceiling for every run of the project:

```yaml nika.yaml theme={"system"}
nika: my-project

ceiling: 0.50
```

> [!NOTE]
>
> `nika init` does much more than create `nika.yaml`: it writes about 30
> agent, editor and hook files and a starter workflow
> ([the full list](https://docs.nika.sh/getting-started/agents.md#nika-init-teach-the-repo)). Run it
> only when you want that scaffold.

Add `arm:` when time or an event should start a workflow, and `traces:` or
`registry:` for run policy: one file carries both. The
[project file](https://docs.nika.sh/sdk/project/nika-yaml.md) and [arm registry](https://docs.nika.sh/sdk/project/arm-registry.md)
pages show copy-paste forms.

## Create one client

```ts theme={"system"}
// src/nika.ts
import { fileURLToPath } from 'node:url'
import { Nika } from '@supernovae-st/nika'

export const nika = new Nika({
  bin: process.env.APP_NIKA_BIN,
  cwd: fileURLToPath(new URL('..', import.meta.url)),
})
```

`fileURLToPath` decodes percent-escapes and survives spaces in the path —
`new URL(...).pathname` does neither.

Binary resolution follows one ladder:

1. `bin` passed to the constructor
2. `NIKA_BIN`
3. exact optional platform package

Use an explicit application variable for packaged services. `bin` and
`NIKA_BIN` must be absolute paths: a bare name or a relative path throws
`NikaConfigurationError`, and a `nika` on your `PATH` is never used. `cwd`
anchors relative workflow paths, project-file discovery and the `.nika/`
state directory.

## Probe at startup

```ts theme={"system"}
try {
  const report = await nika.check('workflows/daily-brief.nika', {
    nativeStrict: true,
  })
  if (!report.clean) {
    console.error('workflow refused at admission', report.findings)
    process.exit(2)
  }
  console.info('nika engine ready')
} catch (error) {
  console.error('cannot start workflow runtime', error)
  process.exit(3)
}
```

A missing binary is an environment failure (the promise rejects). A dirty
workflow is different: `check()` resolves to a report so the caller can show
every finding — branch on `report.clean`, never log readiness while it is
false.

## Keep receipts governed

```text .gitignore theme={"system"}
.nika/
.env
```

Everything under `.nika/` is machine state:

| Path | Holds |
| - | - |
| `.nika/traces/` | run records, which can carry model outputs, file contents and tool arguments |
| `.nika/arm/` | firing claims, receipts and cadence watermarks |
| `.nika/serve/` | `nika serve` job snapshots and schedule state |
| `.nika/serve.token` | the server's bearer token: a secret |
| `.nika/compile/` | recorded compile plans |
| `.nika/approval-claims/` | which human approvals were already used |
| `.nika/quarantine/` | outputs a failed run moved aside, one folder per trace |

> [!WARNING]
>
> Never commit `.nika/serve.token`: it is the bearer token that lets a client
> run workflows on your server.

If a deployment retains this state, choose the volume, retention window and
access policy explicitly.

## Connect the next systems

> [card] [Security boundary](https://docs.nika.sh/sdk/operations/security.md)
>
> Keep permits, secrets, argv and spend ceilings explicit.

> [card] [Local client](https://docs.nika.sh/sdk/local/client.md)
>
> Read every local method and its machine twin.

> [card] [Workflow concepts](https://docs.nika.sh/concepts/workflows.md)
>
> The file remains the language contract.

> [card] [Traces](https://docs.nika.sh/concepts/traces.md)
>
> Understand the durable journal under the SDK receipt.

> [card] [Resident server](https://docs.nika.sh/sdk/operations/resident-server.md)
>
> Keep armed beats running on a container, VM or bare server.

> [card] [Runtime state](https://docs.nika.sh/sdk/project/runtime-state.md)
>
> Persist traces and arming ledgers without committing them.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.