|
| 1 | +--- |
| 2 | +name: "rp-build-cli" |
| 3 | +description: "Build with rp-cli context builder plan → implement" |
| 4 | +repoprompt_managed: true |
| 5 | +repoprompt_skills_version: 30 |
| 6 | +repoprompt_variant: cli |
| 7 | +--- |
| 8 | + |
| 9 | +# CLI Builder Mode (CLI) |
| 10 | + |
| 11 | +Task: $ARGUMENTS |
| 12 | + |
| 13 | +Build deep context via `builder` to get a plan, then implement directly. Use follow-up reasoning only when navigating the selected code proves difficult or the plan leaves a concrete gap. |
| 14 | + |
| 15 | +## Using rp-cli |
| 16 | + |
| 17 | +This workflow uses **rp-cli** (RepoPrompt CLI) instead of MCP tool calls. Run commands via: |
| 18 | + |
| 19 | +```bash |
| 20 | +rp-cli -e '<command>' |
| 21 | +``` |
| 22 | + |
| 23 | +**Quick reference:** |
| 24 | + |
| 25 | +| MCP Tool | CLI Command | |
| 26 | +|----------|-------------| |
| 27 | +| `get_file_tree` | `rp-cli -e 'tree'` | |
| 28 | +| `file_search` | `rp-cli -e 'search "pattern"'` | |
| 29 | +| `get_code_structure` | `rp-cli -e 'structure path/'` | |
| 30 | +| `read_file` | `rp-cli -e 'read path/file.swift'` | |
| 31 | +| `manage_selection` | `rp-cli -e 'select add path/'` | |
| 32 | +| `context_builder` | `rp-cli -e 'builder "instructions" --response-type plan'` | |
| 33 | +| `oracle_send` | `rp-cli -e 'chat "message" --mode plan'` | |
| 34 | +| `apply_edits` | `rp-cli -e 'call apply_edits {"path":"...","search":"...","replace":"..."}'` | |
| 35 | +| `file_actions` | `rp-cli -e 'call file_actions {"action":"create","path":"..."}'` | |
| 36 | + |
| 37 | +Chain commands with `&&`: |
| 38 | +```bash |
| 39 | +rp-cli -e 'select set src/ && context' |
| 40 | +``` |
| 41 | + |
| 42 | +Use `rp-cli -e 'describe <tool>'` for help on a specific tool, `rp-cli --tools-schema` for machine-readable JSON schemas, or `rp-cli --help` for CLI usage. |
| 43 | + |
| 44 | +JSON args (`-j`) accept inline JSON, file paths (`.json` auto-detected), `@file`, or `@-` (stdin). Raw newlines in strings are auto-repaired. |
| 45 | + |
| 46 | +**⚠️ TIMEOUT WARNING:** The `builder` and `chat` commands can take several minutes to complete. When invoking rp-cli, **set your command timeout to at least 2700 seconds (45 minutes)** to avoid premature termination. |
| 47 | + |
| 48 | +--- |
| 49 | +## The Workflow |
| 50 | + |
| 51 | +0. **Verify workspace** – Confirm the target codebase is loaded |
| 52 | +1. **Quick scan** – Understand how the task relates to the codebase |
| 53 | +2. **Context builder** – Call `builder` with a clear prompt to get deep context + an architectural plan |
| 54 | +3. **Only if needed, ask `chat`** – Use it when navigating the selected code is difficult or the plan leaves a concrete unresolved gap |
| 55 | +4. **Implement directly** – Use editing tools to make changes once the plan is clear |
| 56 | + |
| 57 | +--- |
| 58 | + |
| 59 | +## CRITICAL REQUIREMENT |
| 60 | + |
| 61 | +⚠️ **DO NOT START IMPLEMENTATION** until you have: |
| 62 | +1. Completed Phase 0 (Workspace Verification) |
| 63 | +2. Completed Phase 1 (Quick Scan) |
| 64 | +3. **Called `builder`** and received its plan |
| 65 | + |
| 66 | +Skipping `builder` results in shallow implementations that miss architectural patterns, related code, and edge cases. The quick scan alone is NOT sufficient for implementation. |
| 67 | + |
| 68 | +--- |
| 69 | + |
| 70 | +## Phase 0: Workspace Verification (REQUIRED) |
| 71 | + |
| 72 | +Before any exploration, bind to the target codebase using its working directory: |
| 73 | + |
| 74 | +```bash |
| 75 | +# First, list available windows to find the right one |
| 76 | +rp-cli -e 'windows' |
| 77 | + |
| 78 | +# Then check roots in a specific window (REQUIRED - CLI cannot auto-bind) |
| 79 | +rp-cli -w <window_id> -e 'tree --type roots' |
| 80 | +``` |
| 81 | + |
| 82 | +**Check the output:** |
| 83 | +- If your target root appears in a window → note the window ID and proceed to Phase 1 |
| 84 | +- If not → the codebase isn't loaded in any window |
| 85 | + |
| 86 | +**CLI Window Routing (CRITICAL):** |
| 87 | +- CLI invocations are stateless—you MUST pass `-w <window_id>` to target the correct window |
| 88 | +- Use `rp-cli -e 'windows'` to list all open windows and their workspaces |
| 89 | +- Always include `-w <window_id>` in ALL subsequent commands |
| 90 | +- Without `-w`, commands may target the wrong workspace |
| 91 | + |
| 92 | +--- |
| 93 | +## Phase 1: Quick Scan (LIMITED - 2-3 tool calls max) |
| 94 | + |
| 95 | +⚠️ **This phase is intentionally brief.** Do NOT do extensive exploration here—that's what `builder` is for. |
| 96 | + |
| 97 | +Start by getting a lay of the land with the file tree: |
| 98 | +```bash |
| 99 | +rp-cli -w <window_id> -e 'tree' |
| 100 | +``` |
| 101 | + |
| 102 | +Then use targeted searches to understand how the task maps to the codebase: |
| 103 | +```bash |
| 104 | +rp-cli -w <window_id> -e 'search "<key term from task>"' |
| 105 | +rp-cli -w <window_id> -e 'structure RootName/likely/relevant/area/' |
| 106 | +``` |
| 107 | + |
| 108 | +Use what you learn to **reformulate the user's prompt** with added clarity—reference specific modules, patterns, or terminology from the codebase. |
| 109 | + |
| 110 | +**STOP exploring after 2-3 searches.** Your goal is orientation, not deep understanding. `builder` will do the heavy lifting. |
| 111 | + |
| 112 | +--- |
| 113 | + |
| 114 | +## Phase 2: Context Builder |
| 115 | + |
| 116 | +Call `builder` with your informed prompt. Use `response_type: "plan"` to get an actionable architectural plan. |
| 117 | + |
| 118 | +```bash |
| 119 | +rp-cli -w <window_id> -e 'builder "<reformulated prompt with codebase context>" --response-type plan' |
| 120 | +``` |
| 121 | + |
| 122 | +**What you get back:** |
| 123 | +- Smart file selection (automatically curated within token budget) |
| 124 | +- Architectural plan grounded in actual code |
| 125 | +- Chat session for follow-up conversation |
| 126 | +- `tab_id` for targeting the same tab in subsequent CLI invocations |
| 127 | + |
| 128 | +**Tab routing:** Each `rp-cli` invocation is a fresh connection. To continue working in the same tab across separate invocations, pass `-t <tab_id>` (the tab ID returned by builder). |
| 129 | +**Trust `builder`** – it explores deeply, aggregates the relevant context, and selects intelligently. Default to trusting the plan it returns. The `chat` follow-up only reasons over that selected context; it cannot fill coverage gaps on its own. |
| 130 | + |
| 131 | +--- |
| 132 | + |
| 133 | +## Phase 3: Ask `chat` only if needed |
| 134 | + |
| 135 | +`chat` deep-reasons over the files selected by `builder`. It sees those selected files **completely** (full content, not summaries), but it **only sees what's in the selection** — nothing else. |
| 136 | + |
| 137 | +**This phase is optional.** If the builder's plan is already clear and navigation through the selected code is straightforward, proceed straight to Phase 4. |
| 138 | + |
| 139 | +Bring a follow-up to `chat` only when: |
| 140 | +- Navigating the selected code proves difficult even with the builder's plan |
| 141 | +- You need cross-file reasoning over the files already selected |
| 142 | +- The plan leaves a concrete unresolved gap you cannot close by reading the selected files directly |
| 143 | + |
| 144 | +If the answer depends on files outside the current selection, `chat` cannot answer it from thin air. Do **not** turn this workflow into manual selection management by default — if coverage is materially wrong, prefer rerunning `builder` with a better prompt. |
| 145 | + |
| 146 | +```bash |
| 147 | +rp-cli -t '<tab_id>' -e 'chat "The plan points me to X and Y, but I'''m still having trouble tracing how they connect across these selected files. What am I missing, and what edge cases should I watch for?" --mode plan' |
| 148 | +``` |
| 149 | +
|
| 150 | +> **Note:** Pass `-t <tab_id>` to target the same tab across separate CLI invocations. |
| 151 | +
|
| 152 | +**`chat` excels at:** |
| 153 | +- Deep reasoning over the context_builder output and selected files |
| 154 | +- Spotting cross-file connections that piecemeal reading might miss |
| 155 | +- Answering targeted "what am I missing in this selected context" questions |
| 156 | +
|
| 157 | +**Don't expect:** |
| 158 | +- Knowledge of files outside the selection |
| 159 | +- Repository exploration or missing-file discovery — that's `builder`'s job |
| 160 | +- Implementation — that's your job |
| 161 | +
|
| 162 | +--- |
| 163 | +
|
| 164 | +## Phase 4: Direct Implementation |
| 165 | +
|
| 166 | +**STOP** - Before implementing, verify you have: |
| 167 | +- [ ] A builder result available (`tab_id` if follow-up is needed) |
| 168 | +- [ ] An architectural plan grounded in actual code |
| 169 | +
|
| 170 | +If a specific point is still unclear, use `chat` to clarify before proceeding. |
| 171 | +
|
| 172 | +Implement the plan directly. **Do not use `chat` with `mode:"edit"`** – you implement directly. |
| 173 | +
|
| 174 | +**Primary tools:** |
| 175 | +```bash |
| 176 | +# Modify existing files (search/replace) - JSON format required |
| 177 | +rp-cli -w <window_id> -e 'call apply_edits {"path":"Root/File.swift","search":"old","replace":"new"}' |
| 178 | +
|
| 179 | +# Multiline edits |
| 180 | +rp-cli -w <window_id> -e 'call apply_edits {"path":"Root/File.swift","search":"old\ntext","replace":"new\ntext"}' |
| 181 | +
|
| 182 | +# Create new files |
| 183 | +rp-cli -w <window_id> -e 'file create Root/NewFile.swift "content..."' |
| 184 | +
|
| 185 | +# Read specific sections during implementation |
| 186 | +rp-cli -w <window_id> -e 'read Root/File.swift --start-line 50 --limit 30' |
| 187 | +``` |
| 188 | +
|
| 189 | +**Ask `chat` only when navigation or cross-file reasoning is the bottleneck:** |
| 190 | +```bash |
| 191 | +rp-cli -w <window_id> -t '<tab_id>' -e 'chat "I'''m implementing X. The plan does not fully explain Y, and reading the selected files still leaves a gap. What pattern or connection am I missing here?" --mode chat' |
| 192 | +``` |
| 193 | +
|
| 194 | +--- |
| 195 | +
|
| 196 | +## Key Guidelines |
| 197 | +
|
| 198 | +**Token limit:** Stay under ~160k tokens. Check with `select get` if unsure. Context builder manages this, but be aware if you add files. |
| 199 | +
|
| 200 | +**Selection coverage:** |
| 201 | +- `builder` should already have selected the files needed for the plan |
| 202 | +- `chat` can reason only over that selected context; it cannot discover missing files on its own |
| 203 | +- If a material coverage gap blocks you, prefer rerunning `builder` with a better prompt over hand-curating selection |
| 204 | +- Use `manage_selection` only as a last resort for a very small, targeted addition |
| 205 | +
|
| 206 | +**`chat` sees only the selection:** If the answer depends on files outside the selection, `chat` cannot provide it until coverage changes — and in this workflow, coverage changes should usually come from `builder`, not from manual curation. |
| 207 | +
|
| 208 | +--- |
| 209 | +
|
| 210 | +## Anti-patterns to Avoid |
| 211 | +
|
| 212 | +- 🚫 Using `chat` with `mode:"edit"` – implement directly with editing tools |
| 213 | +- 🚫 Asking `chat` about files it cannot see in the current selection |
| 214 | +- 🚫 Treating Phase 3 as mandatory when the builder's plan is already clear |
| 215 | +- 🚫 Reopening or second-guessing the builder's plan by default instead of trusting it |
| 216 | +- 🚫 Leaning on manual `manage_selection` work to patch coverage gaps that should be handled by `builder` |
| 217 | +- 🚫 Skipping `builder` and going straight to implementation – you'll miss context |
| 218 | +- 🚫 Using `manage_selection` with `op:"clear"` – this undoes `builder`'s work; only use small targeted additions if absolutely necessary |
| 219 | +- 🚫 Exceeding ~160k tokens – use slices if needed |
| 220 | +- 🚫 **CRITICAL:** Doing extensive exploration (5+ tool calls) before calling `builder` – the quick scan should be 2-3 calls max |
| 221 | +- 🚫 Reading full file contents during Phase 1 – save that for after `builder` builds context |
| 222 | +- 🚫 Convincing yourself you understand enough to skip `builder` – you don't |
| 223 | +- 🚫 **CLI:** Forgetting to pass `-w <window_id>` – CLI invocations are stateless and require explicit window targeting |
| 224 | +
|
| 225 | +--- |
| 226 | +
|
| 227 | +**Your job:** Get a solid plan from `builder`, trust it by default, use `chat` only when navigating the selected code proves difficult or the plan leaves a concrete unresolved gap, then implement directly and completely. |
0 commit comments