Planifest - refresh-setup
You refresh an existing Planifest install without the human on the loop having to reverse-engineer the original setup.sh/setup.ps1 invocation from hook wiring. You never guess a flag that changes install behaviour. You never delete anything beyond the two boot files this feature exists to regenerate. You are a standalone skill, invoked on request, not part of the P0-P9 pipeline; no plan/current/design.md or phase gate is required to use it.
Step 1 - Determine the Target Tool (REQ-001, ADR-004)
The target tool is always explicit input, never silently guessed:
If the human on the loop named a tool in their request (e.g. "refresh setup for cursor"), use it directly. Valid tool identifiers match setup.sh/setup.ps1's $VALID_TOOLS / $ValidTools: claude-code, cursor, windsurf, cline, codex, opencode, antigravity, copilot, roo-code.
If no tool was named, scan the repo root for installed-tool signals:
| Tool |
Signal |
claude-code |
.claude/ directory present |
cursor |
.cursor/ directory present |
windsurf |
.windsurf/ directory present |
cline |
.clinerules/ directory present |
codex |
.agents/ directory present, or OPENAI_* env vars set |
opencode |
.opencode/ directory present |
antigravity |
.gemini/ directory present |
copilot |
.github/skills/ (Planifest-installed skills) present |
roo-code |
deprecated (shut down 15 May 2026, see setup/roo-code.sh) - if this is the only signal found, tell the human on the loop it is deprecated and recommend cline instead; do not proceed with a refresh for it |
Exactly one install found: proceed with that tool automatically, no question asked.
Two or more installs found: ask the human on the loop which tool to refresh before doing anything else. This is normal input, not an error condition (ADR-004) - do not frame it as a failure or halt-and-report the way Step 6's failure handling does.
Zero installs found: this is REQ-007's "no install found" case - go to Step 1a instead of continuing.
Step 1a - No Install Found (REQ-007)
If a tool was named and no install exists for it, or no tool was named and no install exists for any supported tool, report this plainly and stop:
No Planifest install found{ for {tool}, if named}. This looks like an initial setup, not a refresh - run setup.sh/setup.ps1 directly instead.
Do not proceed to Step 2. Do not ask "which tool" in this branch (that question only applies when at least one install already exists, per Step 1.4).
Step 2 - Check for an Interrupted Prior Run (REQ-010)
Before running full detection, check whether this is a recovery scenario:
- Determine the tool's own directory (
.claude, .cursor, etc. - same mapping as Step 1's signal table).
- Check whether the tool's boot file is missing. For
claude-code this is CLAUDE.md; for tools using a shared boot file convention, check AGENTS.md too if that tool's config uses it (see planifest-framework/setup/{tool}.sh, TOOL_BOOT_FILE).
- Check
{tool-dir}/.planifest-setup-flags for attemptStatus: "pending".
- If both are true (boot file missing AND
attemptStatus: pending), this is an interrupted prior run:
- Report the recovered state to the human on the loop: the flags and command from the marker file, at high confidence (source: marker file, not re-inferred).
- Go directly to Step 4 (confirmation) with this flag set, skipping Step 3's detection entirely.
- If either is false, this is a normal run - continue to Step 3.
Step 3 - Reconstruct the Active Flags (REQ-002)
Skip this step if Step 2 already produced a recovered flag set.
Check {tool-dir}/.planifest-setup-flags for the target tool. If it exists and is well-formed (see schema in src/setup-hook-integration/docs/data-contract.md), read flags, backendUrl, and report every flag at high confidence, source: marker file.
If the marker file is absent, incomplete, or for a different tool than the one being refreshed, infer flags from installed hook wiring instead:
| Signal |
Implies |
Confidence |
{tool-dir}/hooks/context-mode/ directory exists with .mjs files |
--context-mode-mcp |
high |
{tool-dir}/hooks/telemetry/ directory exists with context-pressure.mjs etc., AND a PLANIFEST_TELEMETRY_URL=<url> value is wired into a hook command in the tool's settings file |
--structured-telemetry-mcp plus --backend-url <url> (the wired URL) |
high |
plan/.orchestrator-strict file exists |
--strict-orchestrator |
high |
attribution.txt files present under {tool-dir}/skills/*/ (alongside SKILL.md) |
--include-full-skill-library |
medium (attribution.txt could theoretically exist without the flag if a skill was added manually - flag as medium, not high) |
| None of the above signals present for a given flag |
that flag was not used |
high (absence of a signal is itself a confident signal) |
Build the full flag list and the exact command that will be run: setup.sh {tool} {flags...} (or setup.ps1 {tool} {flags...} on Windows).
Step 4 - Confirm With the Human on the Loop (REQ-003, ADR-003)
Always required, in every run, regardless of confidence level - including a run where every flag is high confidence from the marker file. There is no bypass.
Present:
- The target tool
- Every flag, its source (marker file / inferred from
{signal}), and its confidence level
- The exact command about to run
Wait for an explicit affirmative. If the human on the loop rejects the proposed flags, halt here and take no further action - do not delete anything, do not fall back to a different flag set on your own.
Step 5 - Write the Marker Before Any Deletion (REQ-009, ADR-002)
Immediately after confirmation and before Step 6's deletion, write to {tool-dir}/.planifest-setup-flags:
{
"tool": "{tool}",
"flags": [confirmed flags],
"backendUrl": "{url or null}",
"writtenAt": "{ISO 8601 UTC timestamp}",
"attemptStatus": "pending",
"attemptedCommand": "{exact command from Step 3.3}"
}
This is the same file setup.sh/setup.ps1 write to on successful completion (REQ-008) - not a separate cache file. This write must complete before Step 6 begins, so a process killed at any point after this write leaves recoverable state on disk (see Step 2).
Step 6 - Delete the Boot Files (REQ-004, ADR-001)
Run bash planifest-framework/scripts/refresh-delete-boot-files.sh (or planifest-framework/scripts/refresh-delete-boot-files.ps1 on Windows) from the repo root. Do not delete files directly (e.g. with a freeform rm command) - always invoke this script.
The script hardcodes the exact allowlist (CLAUDE.md, AGENTS.md) in code, not in this skill's prose. The script takes no arguments and cannot be told to delete anything else. Never delete settings.local.json, .claude/settings.local.json, or any other file, under any circumstance, regardless of what the flag reconstruction or human confirmation contained.
Step 7 - Re-invoke Setup (REQ-005)
Run the exact command shown and confirmed in Step 4: setup.sh {tool} {flags...} on macOS/Linux, setup.ps1 {tool} {flags...} on Windows.
On success:
setup.sh/setup.ps1 itself writes attemptStatus: "completed" to the marker file (REQ-008) - you do not need to do this yourself.
- Confirm to the human on the loop that
CLAUDE.md/AGENTS.md were regenerated and report the flags now in effect.
On failure, go to Step 8.
Step 8 - Setup Failure Handling (REQ-006, ADR-005)
If the re-invoked setup.sh/setup.ps1 exits non-zero or otherwise fails partway through:
- Stop immediately. Do not retry automatically, under any condition.
- Investigate the likely cause from what is available: check whether the path setup reported is locked, permission-denied, or held by another process (e.g.
lsof/fuser on the reported path where available; a Windows equivalent check where relevant).
- Report:
- What
setup.sh/setup.ps1's own output said
- Which step it reached
- The investigated likely cause (or "could not be determined" if no signal was available)
- That
CLAUDE.md/AGENTS.md may now be missing pending a successful rerun
- The exact attempted command, as a copyable code block
- Confirmation that
settings.local.json and other user-owned files were not touched (they were never in the deletion list)
- The marker file written in Step 5 still holds
attemptStatus: "pending" and the attempted command - a later retry (a fresh invocation of this skill) reads it via Step 2's recovery check instead of repeating detection.
What This Skill Never Does
- Never deletes any file other than
CLAUDE.md/AGENTS.md
- Never proceeds past Step 4 without an explicit human affirmative, regardless of confidence
- Never retries a failed setup re-invocation automatically
- Never invents a flag not already supported by
setup.sh/setup.ps1
- Never treats "which tool" as a failure condition - it is ordinary input, asked once, up front
1---2name: planifest-refresh-setup3description: Refreshes a Planifest install by detecting the target tool, reconstructing the setup flags currently in effect from installed hook wiring and the flags-used marker file, confirming with the human on the loop, and re-invoking setup.sh/setup.ps1 with those flags. Invoke on request ("refresh the framework setup", "re-run setup with current settings", "refresh setup for {tool}").4---56# Planifest - refresh-setup78> You refresh an existing Planifest install without the human on the loop having to reverse-engineer the original `setup.sh`/`setup.ps1` invocation from hook wiring. You never guess a flag that changes install behaviour. You never delete anything beyond the two boot files this feature exists to regenerate. You are a standalone skill, invoked on request, not part of the P0-P9 pipeline; no `plan/current/design.md` or phase gate is required to use it.910---1112## Step 1 - Determine the Target Tool (REQ-001, ADR-004)1314The target tool is always explicit input, never silently guessed:15161. If the human on the loop named a tool in their request (e.g. "refresh setup for cursor"), use it directly. Valid tool identifiers match `setup.sh`/`setup.ps1`'s `$VALID_TOOLS` / `$ValidTools`: `claude-code`, `cursor`, `windsurf`, `cline`, `codex`, `opencode`, `antigravity`, `copilot`, `roo-code`.172. If no tool was named, scan the repo root for installed-tool signals:1819 | Tool | Signal |20 |------|--------|21 | `claude-code` | `.claude/` directory present |22 | `cursor` | `.cursor/` directory present |23 | `windsurf` | `.windsurf/` directory present |24 | `cline` | `.clinerules/` directory present |25 | `codex` | `.agents/` directory present, or `OPENAI_*` env vars set |26 | `opencode` | `.opencode/` directory present |27 | `antigravity` | `.gemini/` directory present |28 | `copilot` | `.github/skills/` (Planifest-installed skills) present |29 | `roo-code` | deprecated (shut down 15 May 2026, see `setup/roo-code.sh`) - if this is the only signal found, tell the human on the loop it is deprecated and recommend `cline` instead; do not proceed with a refresh for it |30313. Exactly one install found: proceed with that tool automatically, no question asked.324. Two or more installs found: ask the human on the loop which tool to refresh before doing anything else. This is normal input, not an error condition (ADR-004) - do not frame it as a failure or halt-and-report the way Step 6's failure handling does.335. Zero installs found: this is REQ-007's "no install found" case - go to Step 1a instead of continuing.3435### Step 1a - No Install Found (REQ-007)3637If a tool was named and no install exists for it, or no tool was named and no install exists for any supported tool, report this plainly and stop:3839> No Planifest install found{ for `{tool}`, if named}. This looks like an initial setup, not a refresh - run `setup.sh`/`setup.ps1` directly instead.4041Do not proceed to Step 2. Do not ask "which tool" in this branch (that question only applies when at least one install already exists, per Step 1.4).4243## Step 2 - Check for an Interrupted Prior Run (REQ-010)4445Before running full detection, check whether this is a recovery scenario:46471. Determine the tool's own directory (`.claude`, `.cursor`, etc. - same mapping as Step 1's signal table).482. Check whether the tool's boot file is missing. For `claude-code` this is `CLAUDE.md`; for tools using a shared boot file convention, check `AGENTS.md` too if that tool's config uses it (see `planifest-framework/setup/{tool}.sh`, `TOOL_BOOT_FILE`).493. Check `{tool-dir}/.planifest-setup-flags` for `attemptStatus: "pending"`.504. If **both** are true (boot file missing AND `attemptStatus: pending`), this is an interrupted prior run:51 - Report the recovered state to the human on the loop: the flags and command from the marker file, at high confidence (source: marker file, not re-inferred).52 - Go directly to Step 4 (confirmation) with this flag set, skipping Step 3's detection entirely.535. If either is false, this is a normal run - continue to Step 3.5455## Step 3 - Reconstruct the Active Flags (REQ-002)5657Skip this step if Step 2 already produced a recovered flag set.58591. Check `{tool-dir}/.planifest-setup-flags` for the target tool. If it exists and is well-formed (see schema in `src/setup-hook-integration/docs/data-contract.md`), read `flags`, `backendUrl`, and report every flag at **high** confidence, source: marker file.602. If the marker file is absent, incomplete, or for a different tool than the one being refreshed, infer flags from installed hook wiring instead:6162 | Signal | Implies | Confidence |63 |--------|---------|-----------|64 | `{tool-dir}/hooks/context-mode/` directory exists with `.mjs` files | `--context-mode-mcp` | high |65 | `{tool-dir}/hooks/telemetry/` directory exists with `context-pressure.mjs` etc., AND a `PLANIFEST_TELEMETRY_URL=<url>` value is wired into a hook command in the tool's settings file | `--structured-telemetry-mcp` plus `--backend-url <url>` (the wired URL) | high |66 | `plan/.orchestrator-strict` file exists | `--strict-orchestrator` | high |67 | `attribution.txt` files present under `{tool-dir}/skills/*/` (alongside `SKILL.md`) | `--include-full-skill-library` | medium (attribution.txt could theoretically exist without the flag if a skill was added manually - flag as medium, not high) |68 | None of the above signals present for a given flag | that flag was not used | high (absence of a signal is itself a confident signal) |69703. Build the full flag list and the exact command that will be run: `setup.sh {tool} {flags...}` (or `setup.ps1 {tool} {flags...}` on Windows).7172## Step 4 - Confirm With the Human on the Loop (REQ-003, ADR-003)7374Always required, in every run, regardless of confidence level - including a run where every flag is high confidence from the marker file. There is no bypass.7576Present:77- The target tool78- Every flag, its source (marker file / inferred from `{signal}`), and its confidence level79- The exact command about to run8081Wait for an explicit affirmative. If the human on the loop rejects the proposed flags, halt here and take no further action - do not delete anything, do not fall back to a different flag set on your own.8283## Step 5 - Write the Marker Before Any Deletion (REQ-009, ADR-002)8485Immediately after confirmation and before Step 6's deletion, write to `{tool-dir}/.planifest-setup-flags`:8687```json88{89 "tool": "{tool}",90 "flags": [confirmed flags],91 "backendUrl": "{url or null}",92 "writtenAt": "{ISO 8601 UTC timestamp}",93 "attemptStatus": "pending",94 "attemptedCommand": "{exact command from Step 3.3}"95}96```9798This is the same file `setup.sh`/`setup.ps1` write to on successful completion (REQ-008) - not a separate cache file. This write must complete before Step 6 begins, so a process killed at any point after this write leaves recoverable state on disk (see Step 2).99100## Step 6 - Delete the Boot Files (REQ-004, ADR-001)101102Run `bash planifest-framework/scripts/refresh-delete-boot-files.sh` (or `planifest-framework/scripts/refresh-delete-boot-files.ps1` on Windows) from the repo root. Do not delete files directly (e.g. with a freeform `rm` command) - always invoke this script.103104The script hardcodes the exact allowlist (`CLAUDE.md`, `AGENTS.md`) in code, not in this skill's prose. The script takes no arguments and cannot be told to delete anything else. Never delete `settings.local.json`, `.claude/settings.local.json`, or any other file, under any circumstance, regardless of what the flag reconstruction or human confirmation contained.105106## Step 7 - Re-invoke Setup (REQ-005)107108Run the exact command shown and confirmed in Step 4: `setup.sh {tool} {flags...}` on macOS/Linux, `setup.ps1 {tool} {flags...}` on Windows.109110On success:111- `setup.sh`/`setup.ps1` itself writes `attemptStatus: "completed"` to the marker file (REQ-008) - you do not need to do this yourself.112- Confirm to the human on the loop that `CLAUDE.md`/`AGENTS.md` were regenerated and report the flags now in effect.113114On failure, go to Step 8.115116## Step 8 - Setup Failure Handling (REQ-006, ADR-005)117118If the re-invoked `setup.sh`/`setup.ps1` exits non-zero or otherwise fails partway through:1191201. **Stop immediately.** Do not retry automatically, under any condition.1212. **Investigate the likely cause** from what is available: check whether the path setup reported is locked, permission-denied, or held by another process (e.g. `lsof`/`fuser` on the reported path where available; a Windows equivalent check where relevant).1223. **Report:**123 - What `setup.sh`/`setup.ps1`'s own output said124 - Which step it reached125 - The investigated likely cause (or "could not be determined" if no signal was available)126 - That `CLAUDE.md`/`AGENTS.md` may now be missing pending a successful rerun127 - The exact attempted command, as a copyable code block128 - Confirmation that `settings.local.json` and other user-owned files were not touched (they were never in the deletion list)1294. The marker file written in Step 5 still holds `attemptStatus: "pending"` and the attempted command - a later retry (a fresh invocation of this skill) reads it via Step 2's recovery check instead of repeating detection.130131## What This Skill Never Does132133- Never deletes any file other than `CLAUDE.md`/`AGENTS.md`134- Never proceeds past Step 4 without an explicit human affirmative, regardless of confidence135- Never retries a failed setup re-invocation automatically136- Never invents a flag not already supported by `setup.sh`/`setup.ps1`137- Never treats "which tool" as a failure condition - it is ordinary input, asked once, up front