Skip to content
Back to skills

rewind

ASecurity

Roll back the CocoBrew lifecycle to a prior phase commit. Performs a git soft reset to the specified phase ID commit, discards subsequent commits, and updates AGENTS.md phase state. Use with caution — subsequent phase artifacts will be removed.

  • 724 stars
  • 0 votes
  • 0 copies
  • 3 views
  • Added June 5, 2026
ai-agentsnodegit

Security analysis

A100/100

Pro scans all 18 files and shows the line behind each finding

Scanned June 5, 2026

npx -y skills add Snowflake-Labs/cocoplus --skill skills --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of rewind?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for rewind
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/snowflake-labs-rewind/badge)](https://www.skillsdirectory.com/skills/snowflake-labs-rewind)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: "rewind"
description: "Roll back the CocoBrew lifecycle to a prior phase commit. Performs a git soft reset to the specified phase ID commit, discards subsequent commits, and updates AGENTS.md phase state. Use with caution — subsequent phase artifacts will be removed."
version: "1.0.3"
author: "CocoPlus"
tags:
  - cocoplus
  - lifecycle-engine
---

Your objective is to roll back the CocoBrew lifecycle to a prior phase commit.

Before proceeding, verify that `.cocoplus/` exists.
If not: output "CocoPlus not initialized in this directory. Run `$pod init` to begin." Then stop.

## Usage

`$rewind [step-id]` — e.g., `$rewind spec-20260405-001`
`$rewind --tag [tag-name]` — e.g., `$rewind --tag cocoplus/harvest/hr-20260511-4a2f/task-007`
`$rewind --tag task-007` — abbreviated form (last segment only for harvest tags)

If no step-id or tag is provided, list available phase commits and CocoPlus tags:
```
git log --oneline --grep="feat(spec)\|feat(plan)\|build:\|test:\|docs(review)\|release:"
git tag --list "cocoplus/*" --sort=-creatordate | head -20
```

## Tag-Based Rollback (--tag flag)

If `--tag` flag provided:
1. Resolve the full tag name — if abbreviated (e.g., `task-007`), search `git tag --list "cocoplus/harvest/*/task-007"` for the full name
2. If not found: output "Tag [tag-name] not found. Run `git tag --list 'cocoplus/*'` to see available tags." Then stop.
3. Resolve the commit SHA: `git rev-list -n 1 [full-tag-name]`
4. Proceed to Confirm Rollback with the resolved commit SHA and tag name as the step-id display

**Sub-phase tags created by CocoHarvest:**
- Format: `cocoplus/harvest/[run-id]/task-[N]` — created on each CocoHarvest task completion
- Format: `cocoplus/fn/[function-name]/v[N]` — created on each Cortex function deployment stage

## Confirm Rollback

Display what will be removed:
```
git log [target-commit]..HEAD --oneline
```

Output: "Rolling back to [step-id] will remove these commits. This cannot be undone without using git reflog. Continue? (yes/no)"
If no: stop.

## Perform Rollback

Find the commit SHA for the step-id by searching git log for the phase commit message.
Perform a soft reset:
```
git reset --soft [target-commit-sha]
```

## Prune Stale Worktrees

After the reset, remove any CocoHarvest worktrees from the now-removed Build phase to prevent naming collisions on future builds:
```
node -e "
const { execSync } = require('child_process');
try {
  const out = execSync('git worktree list --porcelain').toString();
  const trees = out.split('\n\n').filter(Boolean);
  for (const tree of trees) {
    const lines = tree.trim().split('\n');
    const wtPath = lines[0].replace(/^worktree /, '');
    if (/[/\\\\]agent[/\\\\]stage-/.test(wtPath)) {
      try { execSync('git worktree remove --force \"' + wtPath + '\"'); } catch(_) {}
    }
  }
  execSync('git worktree prune');
} catch(e) { /* worktree cleanup is best-effort */ }
"
```

## Update State

Read the phase from the step-id (e.g., `spec-*` → phase is spec).
Update `.cocoplus/lifecycle/meta.json`: set `current_phase` to the target phase, remove subsequent phases from `phases_completed`.

Update AGENTS.md: replace phase line with rolled-back phase.

Output: "Rolled back to [step-id]. Current phase: [phase]. Subsequent phase artifacts have been unstaged. Stale build worktrees have been pruned. Use `git checkout -- .cocoplus/` to also discard working tree changes if needed."

## Anti-Rationalization

| Shortcut / Temptation | Why It Fails |
|-----------------------|--------------|
| Rewind without showing commit range impact | Developer cannot make an informed rollback decision |
| Use hard reset instead of soft reset | Destroys working changes and increases recovery risk |
| Skip phase-state updates after reset | CocoBrew state diverges from git history and breaks later stages |

## Exit Criteria

- [ ] Available lifecycle commits and CocoPlus tags are shown when no `step-id` or `--tag` is provided
- [ ] Developer receives an explicit confirmation prompt with the commit range to be removed
- [ ] `git reset --soft [target-commit-sha]` is executed only after confirmation
- [ ] `.cocoplus/lifecycle/meta.json` and `.cocoplus/AGENTS.md` phase state are updated to the target lifecycle phase
- [ ] `--tag` abbreviated form resolves to full tag name before rollback
- [ ] Tag not found produces an actionable error with the list command

Files in this skill

  • assist-mode/cocoplus-off.skill.md3.3 KB
  • assist-mode/cocoplus-on.skill.md4.1 KB
  • cocobehavior/SKILL.md3.8 KB
  • cocobloom/bloom-crystallize.skill.md4.8 KB
  • cocobloom/bloom-skip.skill.md1.3 KB
  • cocobloom/bloom.skill.md6.4 KB
  • cocobrew/build.skill.md4.1 KB
  • cocobrew/plan.skill.md6.9 KB
  • cocobrew/review.skill.md5.3 KB
  • cocobrew/ship.skill.md5.6 KB
  • cocobrew/spec.skill.md7.2 KB
  • cocobrew/test.skill.md3.1 KB
  • cocobrew/worktree-utils.md580 B
  • cococontext/context-add.skill.md5.3 KB
  • cococontext/context-list.skill.md2.4 KB
  • cococontext/context-view.skill.md1.8 KB
  • cococupper/cup-history.skill.md1.7 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.