Skip to content
Development
Command

/restore

Restore archived increments back to active folder

From plugin
specweave
15673 skills20 agents73 commands
Install
> /plugin marketplace add anton-abyzov/specweave
> /plugin install sw@specweave

How it fires

How this command gets triggered: by you, by Claude, or both.

  • Fires itselfClaude auto-loads it when your prompt matches the work.
  • You can call itInvoke it directly when you want it.
  • Slash command/restore

Context preview

What this command does when you run it.

Restore archived increments back to active folder

Command definition

restore.md
description: Restore archived increments back to active folder
disable-model-invocation: true

Restore Increment from Archive

Restore an archived increment back to the main increments folder. Useful when you need to reference, update, or continue work on an old increment.

Usage

# Restore specific increment
sw:restore 0031

# Restore multiple increments
sw:restore 0001 0002 0003

# List archived increments
sw:restore --list

Arguments

  • `<increment-ids>`: Increment IDs to restore (e.g., "1", "0001", "0031")
  • `--list`: List all archived increments without restoring

Examples

Example 1: Restore Specific Increment

sw:restore 0031

**Output**:

๐Ÿ“ฆ Restoring increment from archive...

Increment: 0031-external-tool-status-sync
Source: .specweave/increments/_archive/0031-external-tool-status-sync/
Target: .specweave/increments/0031-external-tool-status-sync/

Checking target location...
  โœ“ Target location is empty

โœ… Restored: 0031-external-tool-status-sync
   Location: .specweave/increments/0031-external-tool-status-sync/

๐Ÿ“Š Archive Statistics:
   Active: 33 increments (+ 1 restored)
   Archived: 30 increments (- 1)

Next: sw:do 0031 (to continue work)

Example 2: List Archived Increments

sw:restore --list

**Output**:

๐Ÿ“ฆ Archived Increments:

.specweave/increments/_archive/
โ”œโ”€โ”€ 0001-core-framework (152 days old)
โ”œโ”€โ”€ 0002-plugin-system (148 days old)
โ”œโ”€โ”€ 0003-auth-service (145 days old)
โ”œโ”€โ”€ 0004-payment-integration (142 days old)
โ”œโ”€โ”€ 0005-api-gateway (140 days old)
...
โ”œโ”€โ”€ 0030-jira-integration (35 days old)
โ””โ”€โ”€ 0031-external-tool-status-sync (12 days old)

Total: 31 archived increments

To restore: sw:restore <increment-id>

Example 3: Restore Multiple Increments

sw:restore 0030 0031

**Output**:

๐Ÿ“ฆ Restoring increments from archive...

Restoring 0030-jira-integration...
  โœ… Restored

Restoring 0031-external-tool-status-sync...
  โœ… Restored

โœ… Restored: 2 increments

๐Ÿ“Š Archive Statistics:
   Active: 34 increments (+ 2 restored)
   Archived: 29 increments (- 2)

Error Handling

Increment Not Found in Archive

โŒ Error: Increment 0031 not found in archive

Archive location: .specweave/increments/_archive/

Available archived increments:
  โ€ข 0001-core-framework
  โ€ข 0002-plugin-system
  โ€ข 0003-auth-service
  ...

Use: sw:restore --list to see all

Target Location Already Exists

โŒ Error: Cannot restore 0031 - already exists in active folder

Conflict:
  Archive: .specweave/increments/_archive/0031-external-tool-status-sync/
  Active: .specweave/increments/0031-external-tool-status-sync/

Options:
  1. Delete active version first (if it's a duplicate)
  2. Resolve duplicates: sw:fix-duplicates
  3. Archive active version: sw:archive 0031
  4. Rename one version manually

Recommended: sw:fix-duplicates (auto-resolves conflicts)

Permission Errors

โŒ Error: Permission denied

Could not move:
  From: .specweave/increments/_archive/0031-external-tool-status-sync/
  To: .specweave/increments/0031-external-tool-status-sync/

Check:
  โ€ข File permissions
  โ€ข Disk space
  โ€ข Files not open in another program

Safety Checks

Before restoring, the system checks:

  • โœ… **Increment exists in archive**: Source folder exists
  • โœ… **Target location empty**: No conflict in main folder
  • โœ… **Valid increment structure**: Has required files (metadata.json)
  • โœ… **Disk space available**: Enough space for restored files

Related Commands

  • `sw:archive <increment-id>` - Archive completed increments
  • `sw:status` - View archive statistics
  • `sw:fix-duplicates` - Auto-resolve duplicate increments
  • `sw:do <increment-id>` - Resume work on restored increment

Implementation

import { Task } from '@claude/types';

const task = new Task('restore-increment', 'Restore increment from archive');

task.run(async () => {
  const { IncrementArchiver } = await import('../../../dist/src/core/increment/increment-archiver.js');
  const archiver = new IncrementArchiver(process.cwd());

  // Parse arguments
  const args = process.argv.slice(2);

  // List mode
  if (args.includes('--list')) {
    const archived = await archiver.listArchived();
    console.log('\n๐Ÿ“ฆ Archived Increments:\n');

    if (archived.length === 0) {
      console.log('No archived increments found.');
      return;
    }

    console.log('.specweave/increments/_archive/');
    archived.forEach(inc => {
      console.log(`โ”œโ”€โ”€ ${inc}`);
    });
    console.log(`\nTotal: ${archived.length} archived increments`);
    console.log('\nTo restore: sw:restore <increment-id>');
    return;
  }

  // Restore mode
  const incrementIds = args.filter(arg => !arg.startsWith('--'));

  if (incrementIds.length === 0) {
    console.error('โŒ Error: No increment IDs provided');
    console.log('\nUsage:');
    console.log('  sw:restore <increment-id>');
    console.log('  sw:restore --list');
    return;
  }

  // Restore each increment
  let restored = 0;
  let errors = 0;

  for (const id of incrementIds) {
    try {
      // Normalize ID to 4-digit format
      const normalizedId = id.padStart(4, '0');

      // Find archived increment
      const archived = await archiver.listArchived();
      const match = archived.find(inc => inc.startsWith(normalizedId));

      if (!match) {
        console.error(`โŒ Increment ${normalizedId} not found in archive`);
        errors++;
        continue;
      }

      // Restore increment
      await archiver.restore(match);
      console.log(`โœ… Restored: ${match}`);
      restored++;
    } catch (error) {
      console.error(`โŒ Failed to restore ${id}: ${error.message}`);
      errors++;
    }
  }

  // Show statistics
  if (restored > 0 || errors > 0) {
    console.log('\n๐Ÿ“Š Restore Summary:');
    if (restored > 0) {
      console.log(`   โœ… Restored: ${restored} increment${restored > 1 ? 's' : ''}`);
    }
    if (errors > 0) {
      console.log(`   โŒ Errors: ${errors} increme
Read more
Ships withspecweave

Spec-first AI development: describe a feature โ†’ AI creates spec + plan + tasks, builds autonomously, syncs to GitHub/JIRA. Domain-expert skills for PM, Architect, Frontend, QA learn your patterns permanently. Claude Code, Codex, Cursor, Copilot & more.

Get the whole plugin