> ## 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.

# CWD and monorepos

> Align project discovery, workflow paths, direct-run traces and armed state deliberately.

> [!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.

> [!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.1 SDK release](https://github.com/supernovae-st/nika-client/tree/v0.124.1).

The working directory is not a convenience string. It selects relative
workflow paths, starts project discovery and roots direct-run state.

## Two roots can exist

Project discovery walks from `cwd` toward its ancestors and stops at the first
`nika.yaml`. Direct-run trace storage does not walk upward. It stays under the
process room.

ROOT MAP · DISCOVERY WALKS, STORAGE STAYS

<pre tabIndex="0">
  /repo/apps/api/                 Nika cwd
  &#x20;   ├── .nika/traces/              direct-run receipts
  &#x20;   └── ↑ discover
  &#x20;     /repo/nika.yaml             governing project
  &#x20;     /repo/.nika/arm/            firing ledger
  &#x20;     /repo/.nika/traces/         arm / serve run receipts
</pre>

The arm and serve paths enter the discovered project root before they fire.
Their sidecar and triggered-run traces therefore share the project `.nika/`
directory. A direct `nika run` or local `Nika` call writes under its own `cwd`.

## Recommended: align the process room

Set `Nika`'s `cwd` to the project root when one policy boundary and one
evidence well are the goal.

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

const projectRoot = fileURLToPath(new URL('../../', import.meta.url))

export const nika = new Nika({ cwd: projectRoot })

const run = await nika.run('workflows/release.nika')
const result = await run.result()
```

That one choice aligns:

* relative workflow arguments;
* upward `nika.yaml` discovery;
* direct-run `.nika/traces/`;
* arm and serve `.nika/arm/` plus triggered-run traces.

## Nested project files are real boundaries

MONOREPO · FIRST PROJECT FILE WINS

<pre tabIndex="0">
  /repo/nika.yaml                  platform project
  &#x20;   └── apps/
  &#x20;     ├── api/nika.yaml           API project boundary
  &#x20;     │   └── workflows/
  &#x20;     └── worker/                 inherits /repo/nika.yaml
</pre>

A nested `nika.yaml` is useful when a service needs a separate ceiling or
project profile. It is not a path shortcut. Every process below it now sees a
different control plane.

> [!WARNING]
>
> Review a nested project file like a package boundary. Adding one changes
> policy discovery for every CLI and SDK process started below that directory.

## Probe the production room

Run checks from the exact directory the service manager or container will use:

```sh theme={"system"}
cd /srv/nika/project
nika arm
nika trace ls
nika serve --dry --once
```

A clean report from the repository root does not prove a nested service uses
the same project file or reads the same trace store.

## Path contract by operation

| Operation | Project file | Workflow argument | Generated state |
| - | - | - | - |
| Direct `nika run` | First ancestor from `cwd` | Relative to `cwd` | `cwd/.nika/traces/` |
| Local `Nika.run()` | First ancestor from constructor `cwd` | Relative to constructor `cwd` | `cwd/.nika/traces/` |
| `nika arm fire` | First ancestor from process `cwd` | Relative to discovered project | `project/.nika/arm/` and `project/.nika/traces/` |
| `nika serve` | First ancestor at startup | Relative to discovered project | `project/.nika/arm/` and `project/.nika/traces/` |

## Continue

> [card] [Project setup](https://docs.nika.sh/sdk/start/project-setup.md)
>
> Build the root-aligned directory layout.

> [card] [Runtime state](https://docs.nika.sh/sdk/project/runtime-state.md)
>
> Persist the two evidence lanes deliberately.

> [card] [SDK configuration](https://docs.nika.sh/sdk/reference/configuration.md)
>
> Constructor and call-level precedence.

> [card] [Resident server](https://docs.nika.sh/sdk/operations/resident-server.md)
>
> Operate the project-rooted firer.


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