Skip to content

Commit 7515140

Browse files
Kasper Jungeclaude
authored andcommitted
docs: document script execution environment so users know what env vars and working directory their scripts get
The RALPH_NAME environment variable and script execution context (working directory, env inheritance) were implemented in v0.1.8 but only mentioned in the changelog. Users writing check/context scripts now have a reference section in the primitives page explaining what environment their scripts run in. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent eced96b commit 7515140

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

docs/primitives.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,32 @@ When you run `ralph run docs`:
225225

226226
## Behavior notes
227227

228+
### Script execution environment
229+
230+
When a check or context command (or `run.*` script) runs, ralphify sets up the following environment:
231+
232+
**Working directory:** Always the **project root** (where `ralph.toml` lives), regardless of where the primitive directory is located.
233+
234+
**Environment variables:** Scripts inherit the full parent process environment (`PATH`, `HOME`, etc.). When running a named ralph, ralphify also sets:
235+
236+
| Variable | Value | When set |
237+
|---|---|---|
238+
| `RALPH_NAME` | Name of the current ralph (e.g. `docs`) | Only when running a named ralph via `ralph run docs` |
239+
240+
This lets a single script adapt its behavior based on which ralph is running:
241+
242+
```bash
243+
#!/bin/bash
244+
# .ralphify/checks/tests/run.sh
245+
if [ "$RALPH_NAME" = "docs" ]; then
246+
uv run pytest tests/test_docs.py -x
247+
else
248+
uv run pytest -x
249+
fi
250+
```
251+
252+
`RALPH_NAME` is not set when running the root `RALPH.md` directly (i.e. `ralph run` without a named ralph).
253+
228254
### Execution order
229255

230256
Primitives run in **alphabetical order by directory name**. To control order, use number prefixes: `01-lint/`, `02-typecheck/`, `03-tests/`. All checks run regardless of whether earlier checks pass or fail.

0 commit comments

Comments
 (0)