Store Migration Workflow
Migrate monolithic Zustand stores to domain-specific stores using GOAP planning, hive-mind coordination, and neural pattern learning. Use when refactoring god objects, decomposing state management, or improving architecture grades.
$ Installer
git clone https://github.com/bjpl/california_puzzle_game /tmp/california_puzzle_game && cp -r /tmp/california_puzzle_game/.claude/skills/store-migration-workflow ~/.claude/skills/california_puzzle_game// tip: Run this command in your terminal to install the skill
SKILL.md
name: "Store Migration Workflow" description: "Migrate monolithic Zustand stores to domain-specific stores using GOAP planning, hive-mind coordination, and neural pattern learning. Use when refactoring god objects, decomposing state management, or improving architecture grades."
Store Migration Workflow
What This Skill Does
Orchestrates the migration from monolithic state stores to domain-driven stores using:
- GOAP Planning: A* pathfinding for optimal action sequences
- Hive-Mind Coordination: Collective intelligence for complex refactoring
- Neural Pattern Learning: Train on successful migration patterns
- AgentDB Memory: Persist migration state across sessions
Prerequisites
- Claude Flow v2.0+ (
npx claude-flow@alpha) - Zustand-based state management
- Domain store targets identified
Quick Start
# 1. Initialize hive-mind
npx claude-flow hive-mind init
# 2. Store GOAP world state
# Current: {monolithExists: true, domainStoresCreated: false}
# Goal: {monolithExists: false, domainStoresCreated: true, testsPass: true}
# 3. Generate action plan
# Actions: create_domain_stores → migrate_imports → deprecate_monolith → run_tests → commit
GOAP Action Definitions
Available Actions
| Action | Preconditions | Effects | Cost |
|---|---|---|---|
create_domain_stores | monolith analyzed | domainStoresCreated=true | 5 |
migrate_imports | domainStoresCreated=true | importsUpdated=true | 3 |
remove_export | importsUpdated=true | monolithExported=false | 1 |
deprecate_monolith | monolithExported=false | monolithExists=false | 2 |
run_tests | any | testsPass=true/false | 3 |
commit_changes | testsPass=true | migrationComplete=true | 1 |
Example GOAP Plan
{
"currentState": {
"monolithExists": true,
"monolithExported": true,
"domainStoresCreated": true,
"importsUpdated": true,
"testsPass": "unknown"
},
"goalState": {
"monolithExists": false,
"testsPass": true,
"migrationComplete": true
},
"optimalPath": [
"remove_export",
"deprecate_monolith",
"run_tests",
"commit_changes"
],
"totalCost": 7
}
Hive-Mind Integration
# Spawn refactoring swarm
npx claude-flow hive-mind spawn "Migrate gameStore to domain stores" \
--queen-type tactical \
--max-workers 5 \
--consensus weighted
Worker Specialization
- Analyzer Agent: Identify store responsibilities
- Coder Agent: Create domain stores
- Migrator Agent: Update imports
- Tester Agent: Verify no regressions
- Reviewer Agent: Validate architecture
Neural Pattern Training
# Train on migration patterns
npx claude-flow neural train \
--pattern-type optimization \
--data '{"domain":"store-migration","patterns":["decompose","migrate","verify"]}'
Learned Patterns
- decompose-by-domain: Split by business domain, not technical layer
- migrate-incrementally: One import at a time with tests
- deprecate-not-delete: Add JSDoc deprecation before removal
- verify-continuously: Run tests after each migration step
Memory Persistence
// Store migration state
await memory.store('goap/world-state', currentState, 'goap');
await memory.store('goap/goal-state', goalState, 'goap');
await memory.store('goap/action-log/*', actionResults, 'goap');
// Retrieve for session resume
const worldState = await memory.retrieve('goap/world-state');
Step-by-Step Migration
Phase 1: Analysis
- Identify god object (>500 LOC, >50 methods)
- Map responsibilities to domains
- Create domain store interfaces
Phase 2: Creation
- Create domain stores with single responsibility
- Add store coordinator for cross-store communication
- Export from barrel file
Phase 3: Migration
- Find all monolith imports (
grep -r "useGameStore") - Replace with domain store imports
- Update component selectors
Phase 4: Cleanup
- Remove monolith export from index.ts
- Add deprecation JSDoc to monolith
- Run full test suite
- Commit with migration message
Phase 5: Deletion (Future)
- Verify zero imports remain
- Delete monolith file
- Remove from git history (optional)
Replanning Triggers
| Trigger | Response |
|---|---|
| Test failures | Insert fix_test_failures action |
| Circular deps | Add resolve_circular_deps action |
| Type errors | Insert fix_type_errors action |
| Merge conflicts | Add resolve_conflicts action |
Success Criteria
- All imports migrated to domain stores
- Monolith export removed
- Deprecation JSDoc added
- All tests pass
- TypeScript compiles
- Lint passes
- Architecture grade improved
Troubleshooting
Issue: Circular Dependencies
Solution: Use store coordinator pattern with Zustand subscriptions
Issue: Type Mismatches
Solution: Create shared type definitions in @/types
Issue: Test Failures After Migration
Solution: Update test mocks to use domain stores
Related Skills
agentdb-memory-patterns- Persistent memoryhive-mind-advanced- Collective coordinationgoap-planning- Action planningsparc-methodology- Structured development
References
Created: 2025-12-03 Version: 1.0.0 Category: Architecture Refactoring Difficulty: Intermediate
Repository

bjpl
Author
bjpl/california_puzzle_game/.claude/skills/store-migration-workflow
1
Stars
0
Forks
Updated8h ago
Added1w ago