You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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>
|`[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)|
97
97
|`-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`|
100
98
|`--stop-on-error`|`-s`| off | Stop loop if agent exits non-zero or times out |
101
99
|`--delay`|`-d`|`0`| Seconds to wait between iterations |
102
100
|`--timeout`|`-t`| none | Max seconds per iteration |
103
101
|`--log-dir`|`-l`| none | Directory for iteration log files |
104
102
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.
106
111
107
112
### `ralph status`
108
113
@@ -116,7 +121,7 @@ This command checks:
116
121
117
122
- Whether the prompt file exists
118
123
- 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)
120
125
121
126
If everything is configured correctly, it prints "Ready to run." If not, it tells you exactly what's wrong.
122
127
@@ -126,19 +131,17 @@ Scaffold new primitives. Each command creates a directory under `.ralphify/` wit
126
131
127
132
```bash
128
133
ralph new check <name># Create .ralphify/checks/<name>/CHECK.md
129
-
ralph new instruction <name># Create .ralphify/instructions/<name>/INSTRUCTION.md
130
134
ralph new context <name># Create .ralphify/contexts/<name>/CONTEXT.md
131
135
ralph new ralph <name># Create .ralphify/ralphs/<name>/RALPH.md
132
136
```
133
137
134
138
#### Ralph-scoped primitives
135
139
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
+
Checksand 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.
137
141
138
142
```bash
139
143
ralph new check docs-build --ralph docs # .ralphify/ralphs/docs/checks/docs-build/CHECK.md
140
144
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
Copy file name to clipboardExpand all lines: docs/contributing/codebase-map.md
+12-15Lines changed: 12 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,7 +10,7 @@ Quick orientation guide for anyone working on this codebase — human contributo
10
10
11
11
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.
12
12
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.
14
14
15
15
## Directory structure
16
16
@@ -22,9 +22,8 @@ src/ralphify/ # All source code
22
22
├── manager.py # Multi-run orchestration (concurrent runs via threads)
23
23
├── checks.py # Discover and run validation checks, format failures
24
24
├── contexts.py # Discover and run dynamic data contexts, resolve into prompt
25
-
├── instructions.py # Discover and resolve static text instructions
26
25
├── ralphs.py # Named ralph discovery and resolution (resolve_ralph_source)
### The four primitives and the `Primitive` protocol
72
+
### The three primitives and the `Primitive` protocol
75
73
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.
| Ralph |`RALPH.md`| At run start | Replaces root RALPH.md when selected by name |
84
81
85
82
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.
86
83
87
84
### Placeholder resolution
88
85
89
-
Both contexts and instructions use the same resolver (`resolver.py:resolve_placeholders()`):
86
+
Contexts use the resolver (`resolver.py:resolve_placeholders()`):
90
87
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
93
90
- No placeholders at all — everything appended to the end of the prompt
94
91
95
92
### Event system
@@ -117,14 +114,14 @@ The CLI uses a `ConsoleEmitter` (defined in `_console_emitter.py`) that renders
117
114
1.**`engine.py`** — The core run loop. Uses `RunConfig` and `RunState` (from `_run_types.py`) and `EventEmitter`. This is where iteration logic lives.
118
115
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.
119
116
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.
122
119
123
120
## Traps and gotchas
124
121
125
122
### If you change the primitive marker filenames...
126
123
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.
0 commit comments