xiaohongshu
xiaohongshu
dev-refactoring
AUTO-ACTIVATE when working in flow-state-refactor worktree or refactoring large components. MANDATORY port 5550 for refactor worktree. Extract Vue composables, split large files, reduce component size, baseline testing, zero regressions. Triggers on keywords refactor, composable, extract, split c...
Full skill instructions
This skill AUTOMATICALLY activates when:
/flow-state-refactor/src/composables/REFACTOR WORKTREE EXCLUSIVELY USES PORT 5550
# ✅ CORRECT: Always use port 5550 for flow-state-refactor
cd /mnt/d/MY\ PROJECTS/AI/LLM/AI\ Code\ Gen/my-builds/Productivity/flow-state/flow-state-refactor
# Kill any existing process on 5550
lsof -ti:5550 | xargs kill -9
# Start server on PORT 5550 ONLY
npm run dev -- --port 5550
# Verify running on 5550
lsof -i:5550
curl http://localhost:5550
/flow-state-refactor/ worktree--port 5550Test the ORIGINAL code FIRST to establish proof that features work before refactoring.
# 1. Navigate to ORIGINAL code on main worktree
cd /mnt/d/MY\ PROJECTS/AI/LLM/AI\ Code\ Gen/my-builds/Productivity/flow-state
# 2. Ensure server is running on port 5546
npm run dev
# 3. Test ALL features with Playwright MCP
# - Create comprehensive test plan
# - Document ALL passing tests
# - Take screenshots
# - Record console output
# Baseline Test Results - [Component Name]
**Date**: YYYY-MM-DD
**Branch**: main
**Port**: 5546
**Component**: src/[path]/[ComponentName].vue
**Line Count**: XXXX lines
## Test Results
| Feature | Status | Notes |
|---------|--------|-------|
| Feature 1 | ✅ PASS | Description |
| Feature 2 | ✅ PASS | Description |
| Feature 3 | ✅ PASS | Description |
**Tests Passed**: X/X (100%)
**Ready for Refactoring**: ✅ YES
## Screenshots
- `baseline-feature1.png`
- `baseline-feature2.png`
## Console Output
[No errors in baseline]
// ❌ BAD: Mixed concerns
function useEverything() {
const nodes = ref([])
const handleClick = () => {}
const zoom = ref(1)
const sections = ref([])
// Too much!
}
// ✅ GOOD: Single responsibility
function useCanvasNodes() {
const nodes = ref([])
const syncNodes = () => {}
return { nodes, syncNodes }
}
function useCanvasControls() {
const zoom = ref(1)
const handleZoom = (delta) => {}
return { zoom, handleZoom }
}
// ❌ BAD: Service locator pattern
function useCanvasDragDrop() {
const { project } = useVueFlow() // ❌ Will fail in composable
}
// ✅ GOOD: Dependency injection
function useCanvasDragDrop(
nodes: Ref<Node[]>,
project: (pos: {x: number, y: number}) => {x: number, y: number}
) {
// Use parameters directly
}
// Component calls it:
const { project } = useVueFlow() // ✅ Call in component
const dragDrop = useCanvasDragDrop(nodes, project) // ✅ Pass to composable
useFeatureName.ts (camelCase with use prefix)useFeatureName()// useCanvasNodes.ts
export function useCanvasNodes(
taskStore: any,
canvasStore: any
) {
// Implementation
return {
nodes,
syncNodes
}
}
// NOT: export default useCanvasNodes
Document and enforce initialization dependencies:
// ✅ CORRECT ORDER (in component)
const { viewport, project } = useVueFlow()
// 1. Edges (no dependencies)
const { syncEdges } = useCanvasEdges(...)
// 2. Nodes (depends on nothing)
const { nodes, syncNodes } = useCanvasNodes(...)
// 3. Resize (depends on nodes, syncEdges)
const { resizeState, handleResize... } = useCanvasResize(nodes, syncEdges)
// 4. Drag/Drop (depends on nodes, resizeState, syncEdges, project)
const { handleDrop... } = useCanvasDragDrop(nodes, resizeState, syncEdges, project)
// 5. Context Menus (depends on nodes, syncNodes, syncEdges)
const { handleContextMenu... } = useCanvasContextMenus(nodes, syncNodes, syncEdges)
// 6. Controls (depends on most other composables)
const { handleZoom... } = useCanvasControls(...)
export function useCanvasState() {
const _state = ref({ zoom: 1 })
const state = readonly(_state) // ✅ Prevent external mutations
const setState = (newState: any) => {
_state.value = newState
}
return { state, setState }
}
export function useWindowResize() {
const width = ref(window.innerWidth)
const handleResize = () => {
width.value = window.innerWidth
}
// Add listener
window.addEventListener('resize', handleResize)
// ✅ REQUIRED: Cleanup on unmount
onUnmounted(() => {
window.removeEventListener('resize', handleResize)
})
return { width }
}
# 1. Navigate to REFACTOR worktree
cd /mnt/d/MY\ PROJECTS/AI/LLM/AI\ Code\ Gen/my-builds/Productivity/flow-state/flow-state-refactor
# 2. Kill any processes on port 5550
lsof -ti:5550 | xargs kill -9
# 3. Start server on port 5550
npm run dev -- --port 5550
# 4. Test ALL baseline features again with Playwright MCP
# - Use SAME test plan as baseline
# - Compare results 1:1
# - Document ANY differences
# Integration Test Results - [Component Name]
**Date**: YYYY-MM-DD
**Branch**: refactor/[branch-name]
**Port**: 5550
**Component**: src/[path]/[ComponentName].vue
**Line Count Before**: XXXX lines
**Line Count After**: YYYY lines
**Reduction**: ZZ% (XXXX - YYYY lines saved)
## Refactoring Summary
- **Composables Created**: X
- useFeature1.ts (~XXX lines)
- useFeature2.ts (~XXX lines)
- **Template**: UNCHANGED
- **Styles**: UNCHANGED
## Test Results
| Feature | Baseline | Integration | Regression |
|---------|----------|-------------|------------|
| Feature 1 | ✅ PASS | ✅ PASS | NO |
| Feature 2 | ✅ PASS | ❌ FAIL | **YES** |
| Feature 3 | ✅ PASS | ✅ PASS | NO |
**Tests Passed**: X/X (XX%)
**Regressions Found**: X
**Ready for Merge**: ❌ NO (if any regressions)
## Regressions Identified
1. **Feature 2**: [Description of regression]
- **Root Cause**: [Analysis]
- **Fix Required**: [Solution]
## Console Errors
[List any errors found]
Error: useVueFlow() called in composable instead of component
// ❌ WRONG: Composable calling Vue Flow hook
// useCanvasDragDrop.ts
import { useVueFlow } from '@vue-flow/core'
export function useCanvasDragDrop() {
const { project } = useVueFlow() // ❌ Fails - not in component context
}
// ✅ CORRECT: Component calls hook, passes to composable
// CanvasView.vue
const { project } = useVueFlow() // ✅ In component context
const dragDrop = useCanvasDragDrop(nodes, resizeState, syncEdges, project)
Error: Template accessing wrong nested property
// Node creation in composable
allNodes.push({
id: task.id,
type: 'taskNode',
data: task // ✅ Task object directly
})
// ❌ WRONG: Template trying to access nested property
<template #node-taskNode="nodeProps">
<TaskNode :task="nodeProps.data.task" /> <!-- ❌ data.task doesn't exist -->
</template>
// ✅ CORRECT: Access data directly
<template #node-taskNode="nodeProps">
<TaskNode :task="nodeProps.data" /> <!-- ✅ data IS the task -->
</template>
Error: Passing unwrapped refs to composables
// ❌ WRONG: Passing .value (not reactive)
const nodes = ref([])
useComposable(nodes.value) // ❌ Not reactive
// ✅ CORRECT: Pass ref itself
const nodes = ref([])
useComposable(nodes) // ✅ Reactive
Error: Using composable before its dependencies
// ❌ WRONG: Using dragDrop before nodes defined
const dragDrop = useCanvasDragDrop(nodes, ...)
const nodes = ref([]) // ❌ Too late!
// ✅ CORRECT: Define dependencies first
const nodes = ref([])
const dragDrop = useCanvasDragDrop(nodes, ...) // ✅ nodes exists
docs/refactoring-prd.md - Overall refactoring plandocs/phase1-extraction-plan.md - Composable breakdowndocs/phase2-test-results.md - Baseline test resultsdocs/phase3-integration-test-results.md - Integration test resultsdocs/debug-[issue].md - Debug logs for any regressions/**
* Canvas Drag and Drop Composable
*
* Handles all drag-and-drop interactions for tasks and sections.
*
* @param nodes - Reactive array of Vue Flow nodes
* @param resizeState - Resize state tracking object
* @param syncEdges - Function to synchronize edges after operations
* @param project - Vue Flow coordinate transformation function
*
* @returns Drag/drop event handlers and helper functions
*
* Dependencies:
* - Must be called AFTER useCanvasNodes and useCanvasResize
* - Requires project function from useVueFlow() in component
*/
export function useCanvasDragDrop(
nodes: Ref<Node[]>,
resizeState: Ref<any>,
syncEdges: () => void,
project: (position: { x: number; y: number }) => { x: number; y: number }
) {
// Implementation
}
use*)// Add during debugging, remove before merge
console.log('[ComposableName] 🎯 Function called with:', params)
console.log('[ComposableName] ✅ Operation complete')
console.log('[ComposableName] ❌ Error:', error)
# Always check port before starting
lsof -i:5550
# Kill if occupied
lsof -ti:5550 | xargs kill -9
# Start with specific port
npm run dev -- --port 5550
# Verify running
curl http://localhost:5550
// ✅ Use computed for derived state
const filteredTasks = computed(() =>
tasks.value.filter(t => t.status !== 'done')
)
// ❌ Don't recalculate on every render
const getFilteredTasks = () =>
tasks.value.filter(t => t.status !== 'done')
import { useDebounceFn } from '@vueuse/core'
const debouncedSave = useDebounceFn(() => {
saveToDatabase()
}, 1000)
This skill ensures systematic, regression-free refactoring with mandatory baseline testing and port 5550 enforcement for the refactor worktree.
CRITICAL: Before claiming ANY issue, bug, or problem is "fixed", "resolved", "working", or "complete", the following verification protocol is MANDATORY:
REQUIRED: Use the AskUserQuestion tool to explicitly ask the user to verify the fix:
"I've implemented [description of fix]. Before I mark this as complete, please verify:
1. [Specific thing to check #1]
2. [Specific thing to check #2]
3. Does this fix the issue you were experiencing?
Please confirm the fix works as expected, or let me know what's still not working."
Remember: The user is the final authority on whether something is fixed. No exceptions.
xiaohongshu
technical spec
product ux expert
database patterns
Conduct multi-agent task orchestration and workflow coordination.
Initialize project with Conductor artifacts (product definition,
Expert in web animations, transitions, and motion design using Framer Motion and CSS
Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...
PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.
Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...
Display project status, active tracks, and next actions
Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.
Generate, edit, and beat-sync AI video with leading models in one workspace.
The world's fastest calendar for remote work
Transform Your Design with AI Designer by ImgCreator.ai
Revolutionizing Video Production with AI-Powered Creativity
Extend an image past the frame and let AI fill the new aspect ratio.
Discover your celebrity doppelgänger with StarByFace!
ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.
Opus.ai: Revolutionize Your Web Experience