Skip to content

Commit 0b39bab

Browse files
Kasper Jungeclaude
authored andcommitted
docs: simplify getting started, trim cookbook, update docs for removed instructions primitive and new prompt resolution
Remove instructions primitive references across all docs and tests. Replace -p/--prompt and -f/--ralph-file CLI flags with a single smart positional [PROMPT] argument. Trim getting-started (remove Claude Code install, pipx/pip tabs, tips section) and cookbook (keep only docs and coverage recipes). Closes #10. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 632a352 commit 0b39bab

12 files changed

Lines changed: 159 additions & 683 deletions

File tree

docs/cli.md

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ Start the autonomous coding loop.
8383
ralph run # Run forever (Ctrl+C to stop)
8484
ralph run docs # Use the "docs" named ralph
8585
ralph run -n 5 # Run 5 iterations
86-
ralph run -p "Fix the login bug" # Ad-hoc prompt (no RALPH.md needed)
87-
ralph run -f path/to/prompt.md # Use a specific prompt file
86+
ralph run "Fix the login bug" # Ad-hoc inline prompt
87+
ralph run path/to/prompt.md # Use a specific prompt file
8888
ralph run --stop-on-error # Stop if agent exits non-zero
8989
ralph run --delay 10 # Wait 10s between iterations
9090
ralph run --timeout 300 # Kill agent after 5 minutes per iteration
@@ -93,16 +93,21 @@ ralph run --log-dir ralph_logs # Save output to log files
9393

9494
| Argument / Option | Short | Default | Description |
9595
|---|---|---|---|
96-
| `[RALPH_NAME]` | | none | Name of a [named ralph](primitives.md#ralphs) in `.ralphify/ralphs/` |
96+
| `[PROMPT]` | | none | Ralph name, file path, or inline prompt text (see resolution below) |
9797
| `-n` | | unlimited | Max number of iterations |
98-
| `--prompt` | `-p` | none | Ad-hoc prompt text. Overrides the ralph file |
99-
| `--ralph-file` | `-f` | none | Path to a ralph file. Overrides `ralph.toml` |
10098
| `--stop-on-error` | `-s` | off | Stop loop if agent exits non-zero or times out |
10199
| `--delay` | `-d` | `0` | Seconds to wait between iterations |
102100
| `--timeout` | `-t` | none | Max seconds per iteration |
103101
| `--log-dir` | `-l` | none | Directory for iteration log files |
104102

105-
Ad-hoc prompts (`-p`) still resolve context and instruction placeholders. When `-p` is provided, `RALPH.md` doesn't need to exist.
103+
The `[PROMPT]` argument is smart — it resolves in order:
104+
105+
1. If it matches a named ralph in `.ralphify/ralphs/` → use that ralph
106+
2. If it's an existing file path → use as prompt file
107+
3. Otherwise → treat as inline prompt text
108+
4. If omitted → fall back to `ralph.toml` `agent.ralph`
109+
110+
Inline prompts still resolve context placeholders. When inline text is provided, `RALPH.md` doesn't need to exist.
106111

107112
### `ralph status`
108113

@@ -116,7 +121,7 @@ This command checks:
116121

117122
- Whether the prompt file exists
118123
- Whether the agent command is on PATH
119-
- All discovered checks, contexts, instructions, and named ralphs (with enabled/disabled status)
124+
- All discovered checks, contexts, and named ralphs (with enabled/disabled status)
120125

121126
If everything is configured correctly, it prints "Ready to run." If not, it tells you exactly what's wrong.
122127

@@ -126,19 +131,17 @@ Scaffold new primitives. Each command creates a directory under `.ralphify/` wit
126131

127132
```bash
128133
ralph new check <name> # Create .ralphify/checks/<name>/CHECK.md
129-
ralph new instruction <name> # Create .ralphify/instructions/<name>/INSTRUCTION.md
130134
ralph new context <name> # Create .ralphify/contexts/<name>/CONTEXT.md
131135
ralph new ralph <name> # Create .ralphify/ralphs/<name>/RALPH.md
132136
```
133137

134138
#### Ralph-scoped primitives
135139

136-
Checks, contexts, and instructions accept a `--ralph` option to create them inside a named ralph's directory. These [ralph-scoped primitives](primitives.md#ralph-scoped-primitives) only apply when running that specific ralph.
140+
Checks and contexts accept a `--ralph` option to create them inside a named ralph's directory. These [ralph-scoped primitives](primitives.md#ralph-scoped-primitives) only apply when running that specific ralph.
137141

138142
```bash
139143
ralph new check docs-build --ralph docs # .ralphify/ralphs/docs/checks/docs-build/CHECK.md
140144
ralph new context doc-coverage --ralph docs # .ralphify/ralphs/docs/contexts/doc-coverage/CONTEXT.md
141-
ralph new instruction writing-style --ralph docs # .ralphify/ralphs/docs/instructions/writing-style/INSTRUCTION.md
142145
```
143146

144147
| Option | Description |

docs/contributing/codebase-map.md

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Quick orientation guide for anyone working on this codebase — human contributo
1010

1111
Ralphify is a CLI tool (`ralph`) that runs AI coding agents in autonomous loops. It reads a prompt file, pipes it to an agent command (e.g. `claude -p`), waits for it to finish, then repeats. Each iteration gets a fresh context window. Progress is tracked through git commits.
1212

13-
The core loop is simple. The complexity lives in **prompt assembly** — resolving contexts, instructions, and check failures into the prompt before each iteration.
13+
The core loop is simple. The complexity lives in **prompt assembly** — resolving contexts and check failures into the prompt before each iteration.
1414

1515
## Directory structure
1616

@@ -22,9 +22,8 @@ src/ralphify/ # All source code
2222
├── manager.py # Multi-run orchestration (concurrent runs via threads)
2323
├── checks.py # Discover and run validation checks, format failures
2424
├── contexts.py # Discover and run dynamic data contexts, resolve into prompt
25-
├── instructions.py # Discover and resolve static text instructions
2625
├── ralphs.py # Named ralph discovery and resolution (resolve_ralph_source)
27-
├── resolver.py # Template placeholder resolution (shared by contexts + instructions)
26+
├── resolver.py # Template placeholder resolution (used by contexts)
2827
├── detector.py # Auto-detect project type from manifest files
2928
├── _agent.py # Run agent subprocesses (streaming + blocking modes, log writing)
3029
├── _run_types.py # RunConfig, RunState, RunStatus — shared data types for the engine
@@ -54,15 +53,14 @@ ralph run
5453
5554
├── cli.py:run() — parse options, print banner
5655
│ ├── Load config from ralph.toml
57-
│ ├── Resolve prompt via ralphs.resolve_ralph_source() (--prompt > name > --ralph-file > toml > root)
56+
│ ├── Resolve prompt via ralphs.resolve_ralph_source() (name > file path > inline text > toml)
5857
│ └── Build RunConfig and call engine.run_loop()
5958
6059
└── engine.py:run_loop(config, state, emitter)
61-
├── Discover checks, contexts, instructions from .ralphify/
60+
├── Discover checks, contexts from .ralphify/
6261
└── Loop:
6362
├── Read RALPH.md (or use ad-hoc text)
6463
├── Run contexts → resolve {{ contexts.* }} placeholders
65-
├── Resolve {{ instructions.* }} placeholders
6664
├── Append check failures from previous iteration (if any)
6765
├── Pipe assembled prompt to agent command via subprocess
6866
├── Emit iteration events (started, completed, failed, timed_out)
@@ -71,25 +69,24 @@ ralph run
7169
└── Repeat
7270
```
7371

74-
### The four primitives and the `Primitive` protocol
72+
### The three primitives and the `Primitive` protocol
7573

76-
All four primitive types follow the same pattern: a directory under `.ralphify/` with a marker markdown file containing YAML frontmatter. Each type's dataclass (`Check`, `Context`, `Instruction`, `Ralph`) satisfies the `Primitive` protocol defined in `_discovery.py`, which requires `name` and `enabled` properties. This enables type-safe generic functions for discovery, filtering, merging, and display — the engine's `_discover_and_filter_enabled()` helper uses the protocol to handle all four types through a single code path.
74+
All three primitive types follow the same pattern: a directory under `.ralphify/` with a marker markdown file containing YAML frontmatter. Each type's dataclass (`Check`, `Context`, `Ralph`) satisfies the `Primitive` protocol defined in `_discovery.py`, which requires `name` and `enabled` properties. This enables type-safe generic functions for discovery, filtering, merging, and display — the engine's `_discover_and_filter_enabled()` helper uses the protocol to handle all three types through a single code path.
7775

7876
| Primitive | Marker file | Runs | Injects into prompt |
7977
|---|---|---|---|
8078
| Check | `CHECK.md` | After iteration | Failures appended to next prompt |
8179
| Context | `CONTEXT.md` | Before iteration | Output replaces `{{ contexts.name }}` |
82-
| Instruction | `INSTRUCTION.md` | Before iteration | Content replaces `{{ instructions.name }}` |
8380
| Ralph | `RALPH.md` | At run start | Replaces root RALPH.md when selected by name |
8481

8582
Discovery is handled by `_discovery.py:discover_primitives()` which scans `.ralphify/{kind}/*/` for marker files. The engine groups enabled primitives into an `EnabledPrimitives` NamedTuple for clean parameter passing.
8683

8784
### Placeholder resolution
8885

89-
Both contexts and instructions use the same resolver (`resolver.py:resolve_placeholders()`):
86+
Contexts use the resolver (`resolver.py:resolve_placeholders()`):
9087

91-
- `{{ contexts.git-log }}` — named placement for a specific primitive
92-
- `{{ contexts }}` — bulk placement for all remaining primitives
88+
- `{{ contexts.git-log }}` — named placement for a specific context
89+
- `{{ contexts }}` — bulk placement for all remaining contexts
9390
- No placeholders at all — everything appended to the end of the prompt
9491

9592
### Event system
@@ -117,14 +114,14 @@ The CLI uses a `ConsoleEmitter` (defined in `_console_emitter.py`) that renders
117114
1. **`engine.py`** — The core run loop. Uses `RunConfig` and `RunState` (from `_run_types.py`) and `EventEmitter`. This is where iteration logic lives.
118115
2. **`_run_types.py`**`RunConfig`, `RunState`, and `RunStatus`. These are the shared data types used by the engine, CLI, and manager. Separated so modules that only need the types don't pull in execution logic.
119116
3. **`cli.py`** — All CLI commands. Delegates to `engine.run_loop()` for the actual loop. Prompt source resolution (name vs. file path vs. inline) lives in `ralphs.py:resolve_ralph_source()`. Scaffold templates live in `_templates.py`. Terminal event rendering lives in `_console_emitter.py`.
120-
4. **`_frontmatter.py`** + **`_discovery.py`** — Frontmatter parsing and primitive discovery. `_frontmatter.py` handles YAML parsing and defines marker constants. `_discovery.py` defines the `Primitive` protocol, scans `.ralphify/` directories, and provides `merge_by_name()` for overlaying ralph-scoped primitives on globals. Understanding both is essential for working on checks/contexts/instructions/ralphs.
121-
5. **`resolver.py`** — Template placeholder logic shared by contexts and instructions. Small file but critical — changes here affect both.
117+
4. **`_frontmatter.py`** + **`_discovery.py`** — Frontmatter parsing and primitive discovery. `_frontmatter.py` handles YAML parsing and defines marker constants. `_discovery.py` defines the `Primitive` protocol, scans `.ralphify/` directories, and provides `merge_by_name()` for overlaying ralph-scoped primitives on globals. Understanding both is essential for working on checks/contexts/ralphs.
118+
5. **`resolver.py`** — Template placeholder logic used by contexts. Small file but critical.
122119

123120
## Traps and gotchas
124121

125122
### If you change the primitive marker filenames...
126123

127-
The marker file names (`CHECK.md`, `CONTEXT.md`, `INSTRUCTION.md`, `RALPH.md`) are defined as constants in `_frontmatter.py` (`CHECK_MARKER`, `CONTEXT_MARKER`, `INSTRUCTION_MARKER`, `RALPH_MARKER`). The primitives directory name is `PRIMITIVES_DIR`. All modules — `checks.py`, `contexts.py`, `instructions.py`, `ralphs.py`, and `cli.py` — import from there. Change the constant to rename everywhere.
124+
The marker file names (`CHECK.md`, `CONTEXT.md`, `RALPH.md`) are defined as constants in `_frontmatter.py` (`CHECK_MARKER`, `CONTEXT_MARKER`, `RALPH_MARKER`). The primitives directory name is `PRIMITIVES_DIR`. All modules — `checks.py`, `contexts.py`, `ralphs.py`, and `cli.py` — import from there. Change the constant to rename everywhere.
128125

129126
### If you change frontmatter fields...
130127

0 commit comments

Comments
 (0)