From rapid
Migrate .planning/ state from older RAPID versions to current version
npx claudepluginhub pragnition/pragnition-public-plugins --plugin rapidThis skill is limited to using the following tools:
You are the RAPID migration orchestrator. This skill detects the current version of a project's `.planning/` state, compares it against the running RAPID version, and guides an interactive migration to bring state files up to date.
Searches, retrieves, and installs Agent Skills from prompts.chat registry using MCP tools like search_skills and get_skill. Activates for finding skills, browsing catalogs, or extending Claude.
Searches prompts.chat for AI prompt templates by keyword or category, retrieves by ID with variable handling, and improves prompts via AI. Use for discovering or enhancing prompts.
Checks Next.js compilation errors using a running Turbopack dev server after code edits. Fixes actionable issues before reporting complete. Replaces `next build`.
You are the RAPID migration orchestrator. This skill detects the current version of a project's .planning/ state, compares it against the running RAPID version, and guides an interactive migration to bring state files up to date.
Dry-run mode: If the user's invocation includes --dry-run or the user says "dry run", set a DRY_RUN flag. In dry-run mode, proposed changes are displayed but NOT applied. The skill ends after showing the diff.
Follow these steps IN ORDER. Do not skip steps. Use AskUserQuestion at every decision point.
Load environment variables before any CLI calls:
if [ -z "${RAPID_TOOLS:-}" ] && [ -n "${CLAUDE_SKILL_DIR:-}" ] && [ -f "${CLAUDE_SKILL_DIR}/../../.env" ]; then export $(grep -v '^#' "${CLAUDE_SKILL_DIR}/../../.env" | xargs); fi
if [ -z "${RAPID_TOOLS}" ]; then echo "[RAPID ERROR] RAPID_TOOLS is not set. Run /rapid:install or ./setup.sh to configure RAPID."; exit 1; fi
Use this environment preamble in ALL subsequent Bash commands within this skill. Every node "${RAPID_TOOLS}" call must be preceded by the env loading block above in the same Bash invocation.
Run version detection:
if [ -z "${RAPID_TOOLS:-}" ] && [ -n "${CLAUDE_SKILL_DIR:-}" ] && [ -f "${CLAUDE_SKILL_DIR}/../../.env" ]; then export $(grep -v '^#' "${CLAUDE_SKILL_DIR}/../../.env" | xargs); fi
if [ -z "${RAPID_TOOLS}" ]; then echo "[RAPID ERROR] RAPID_TOOLS is not set. Run /rapid:install or ./setup.sh to configure RAPID."; exit 1; fi
node "${RAPID_TOOLS}" migrate detect
Parse the JSON output. Extract detected, confidence, and signals fields.
detected is null: display "Could not detect current RAPID version. No state files found in .planning/." and end the skill.Detected RAPID version: {detected}
Confidence: {confidence}
Signals:
- {signal1}
- {signal2}
...
Run the latest-version check:
if [ -z "${RAPID_TOOLS:-}" ] && [ -n "${CLAUDE_SKILL_DIR:-}" ] && [ -f "${CLAUDE_SKILL_DIR}/../../.env" ]; then export $(grep -v '^#' "${CLAUDE_SKILL_DIR}/../../.env" | xargs); fi
if [ -z "${RAPID_TOOLS}" ]; then echo "[RAPID ERROR] RAPID_TOOLS is not set. Run /rapid:install or ./setup.sh to configure RAPID."; exit 1; fi
node "${RAPID_TOOLS}" migrate is-latest
Parse the JSON output. Extract isLatest, detected, and current fields.
isLatest is true: display "Already at latest version ({current}). No migration needed." and end the skill.Use AskUserQuestion to ask the user to confirm the detected version is correct:
If "No, the version is different": use a follow-up AskUserQuestion freeform to ask "What is the correct source version?" and use the user's answer as the detected version for the rest of the flow.
If "Cancel migration": end the skill.
Run the backup command:
if [ -z "${RAPID_TOOLS:-}" ] && [ -n "${CLAUDE_SKILL_DIR:-}" ] && [ -f "${CLAUDE_SKILL_DIR}/../../.env" ]; then export $(grep -v '^#' "${CLAUDE_SKILL_DIR}/../../.env" | xargs); fi
if [ -z "${RAPID_TOOLS}" ]; then echo "[RAPID ERROR] RAPID_TOOLS is not set. Run /rapid:install or ./setup.sh to configure RAPID."; exit 1; fi
node "${RAPID_TOOLS}" migrate backup
Parse the JSON output. Display the backup location and file count:
Backup created: {backupPath}
Files backed up: {fileCount}
If backup fails (e.g., backup already exists), display the error and use AskUserQuestion:
If "Remove existing backup and retry":
if [ -z "${RAPID_TOOLS:-}" ] && [ -n "${CLAUDE_SKILL_DIR:-}" ] && [ -f "${CLAUDE_SKILL_DIR}/../../.env" ]; then export $(grep -v '^#' "${CLAUDE_SKILL_DIR}/../../.env" | xargs); fi
if [ -z "${RAPID_TOOLS}" ]; then echo "[RAPID ERROR] RAPID_TOOLS is not set. Run /rapid:install or ./setup.sh to configure RAPID."; exit 1; fi
node "${RAPID_TOOLS}" migrate cleanup
node "${RAPID_TOOLS}" migrate backup
If "Cancel migration": end the skill.
This is the core migration logic. You (the agent running this skill) must dynamically analyze the gap between the current .planning/ state and what the running RAPID version expects.
Read the following files from .planning/ (skip any that do not exist):
.planning/STATE.json -- the main state file.planning/ROADMAP.md -- the roadmap document.planning/config.json -- project configuration.planning/DAG.json or .planning/sets/DAG.json -- dependency graph.planning/sets/*/CONTRACT.json -- set contracts.planning/sets/*/SET-OVERVIEW.md -- set overviewsRead these files from the RAPID codebase to understand the target format:
src/lib/state-schemas.cjs -- Zod schemas defining the expected STATE.json structuresrc/lib/state-machine.cjs -- state management patterns and valid transitionssrc/lib/init.cjs -- how a fresh project is scaffolded (the "target" format)Compare the existing .planning/ state against what the current RAPID version expects. Build a structured list of proposed changes. Each change should have:
modify, create, or deleteCommon migrations to look for:
rapidVersion field in STATE.json -- add it with the current RAPID version string.planning/context/ directory -- create it if the current version expects itconfig.json -- create with default structure if absent.planning/DAG.json to .planning/sets/DAG.json if neededDisplay all proposed changes in a human-readable diff-style format:
## Proposed Migration Changes ({count} total)
### 1. {action}: {file}
{description}
Before:
{before snippet or "N/A"}
After:
{after snippet or "N/A"}
### 2. {action}: {file}
...
If there are NO changes needed (everything already matches), display "No changes needed. State is compatible with current version." and skip to cleanup.
If DRY_RUN is active: display the changes and end the skill with:
Dry run complete. No changes written.
To apply these changes, run /rapid:migrate without --dry-run.
If not dry run, use AskUserQuestion:
If "Cancel and restore backup":
if [ -z "${RAPID_TOOLS:-}" ] && [ -n "${CLAUDE_SKILL_DIR:-}" ] && [ -f "${CLAUDE_SKILL_DIR}/../../.env" ]; then export $(grep -v '^#' "${CLAUDE_SKILL_DIR}/../../.env" | xargs); fi
if [ -z "${RAPID_TOOLS}" ]; then echo "[RAPID ERROR] RAPID_TOOLS is not set. Run /rapid:install or ./setup.sh to configure RAPID."; exit 1; fi
node "${RAPID_TOOLS}" migrate restore
Display "Backup restored. No changes applied." and end the skill.
If "Apply all changes":
Apply each proposed change using the appropriate tool:
rm to remove deprecated filesAfter applying all changes, ensure rapidVersion is stamped in STATE.json with the current RAPID version. If this was not already part of the proposed changes, add it now using Edit.
Remove the pre-migration backup:
if [ -z "${RAPID_TOOLS:-}" ] && [ -n "${CLAUDE_SKILL_DIR:-}" ] && [ -f "${CLAUDE_SKILL_DIR}/../../.env" ]; then export $(grep -v '^#' "${CLAUDE_SKILL_DIR}/../../.env" | xargs); fi
if [ -z "${RAPID_TOOLS}" ]; then echo "[RAPID ERROR] RAPID_TOOLS is not set. Run /rapid:install or ./setup.sh to configure RAPID."; exit 1; fi
node "${RAPID_TOOLS}" migrate cleanup
Print the migration report to stdout (do NOT write it as a file):
## Migration Report
- **From:** {detectedVersion}
- **To:** {currentVersion}
- **Changes applied:** {count}
- **Backup:** Cleaned up
- **Status:** Success
### Changes Applied
1. {action}: {file} -- {description}
2. {action}: {file} -- {description}
...
.planning/. Migration only touches planning state files..planning/ state files are in scope.