Communitygithub.com

後端主導的執行時重構

重構應用程式,讓後端擁有執行時的真實狀態,UI 僅作為快照投影。當工具出現權責分離問題時使用。不適用於純 UI 美化或尚未消除權責分裂前的新功能開發。

後端主導的執行時重構 是什麼?

這個技能針對前端與後端之間存在「權責分裂」的應用架構進行重構,確保執行時的真實狀態(runtime truth)完全由後端擁有,UI 僅作為狀態的快照投影(projection)。它特別適合解決以下問題:UI 自行合成後端無法理解的圖形、階段或供應商選擇;重新啟動或重新連線時因前端快取了權威狀態而導致可視狀態變化;以及新舊 schema、起手格式或節點類型並存於活躍編輯路徑中。此技能支援 Claude Code、Cursor 等 AI 代理工具,並提供逐步的工作方法:清查分裂點、凍結合約、正規化狀態所有權、刪除活躍相容層,以及增加評估器。它明確指出失敗模式(例如投影偽裝成權威、相容層僵化、無可檢視性的審批、不利於重播的啟動)和品質關卡,確保重構後 UI 無法偽造圖形、階段或供應商狀態,所有使用者操作皆映射至指令、查詢或事件,且執行時狀態僅依靠後端即可在重啟與重連後復原。

相容平台✓Claude Code~Codex CLI~Cursor
npx skills add https://github.com/curiositech/windags-skills/tree/HEAD/skills/backend-authoritative-runtime-refactor

在你喜歡的 AI 中提問

開啟一個已預先載入此 Agent Skill 的新對話。

說明文件

後端主導的執行時重構 是做什麼的?

僅在你清楚知道執行時真實狀態存在於何處,以及 UI 如何讀取該狀態之後,才能進行重構。

使用時機

  • UI 自行合成後端無法理解的圖形、階段或供應商選擇。
  • 重新啟動或重新連線時,因為前端快取了權威狀態而導致可視執行時狀態發生變化。
  • 新舊 schema、起手格式或節點類型並存於活躍的編輯路徑中。
  • 審批、審查或下游執行依賴僅存在於前端的重建結果。

不適用於

  • 純 UI 視覺美化,且不改變執行時狀態的所有權。
  • 後端合約已是權威來源的獨立元件重構。
  • 在尚未消除權責分裂的接縫之前,推出新的業務功能。
  • 純後端效能優化,且架構已具有單一真實來源。

決策點

flowchart TD
  A[工作流程重構請求] --> B{UI 是否仍能創造執行時真實狀態?}
  B -->|否| C[使用較狹隘的領域或 UI 技能]
  B -->|是| D[盤點指令、查詢與事件接縫]
  D --> E{每個使用者操作都能對應到指令、查詢或事件嗎?}
  E -->|否| F[在功能開發前凍結合約]
  E -->|是| G[將投影狀態與後端擁有的狀態分離]
  G --> H{舊有相容路徑是否仍處於活躍狀態?}
  H -->|是| I[將其移至遷移邊緣或直接刪除]
  H -->|否| J[加入評估器、可重播的啟動查詢,以及事件訂閱]
  I --> J
  J --> K[驗證重新連線、審批與下游就緒狀態]

請優先使用此路由模型:

  • 若 UI 無法被描述為 指令 -> 後端轉換 -> 查詢或事件投影,則接縫仍然不正確。
  • 若「暫時相容」路徑位於熱路徑中,請將其視為重構債務,而非功能。
  • 若重新啟動或重新連線無法僅憑後端真實狀態重建可視狀態,則重構尚未完成。

工作方法

1. 清查分裂的大腦

找出所有 UI 執行下列操作的地方:

  • 產生或變異執行時真實狀態
  • 創造後端不知道的階段
  • 在活躍程式碼路徑中模擬執行
  • 在同一編輯路徑中保留新舊 schema
  • 混合抽象路由層級與確切的供應商 ID

2. 凍結合約

僅定義三種類別:

  • 指令:開始、停止、批准、恢復、變異
  • 查詢:啟動狀態、審查負載、執行快照、供應商健康度
  • 事件:權威轉換、評估器裁決、關卡狀態、重播標記

若 UI 操作無法被表達為上述三者之一,則架構仍然模糊不清。

3. 正規化狀態所有權

將儲存拆分為:

  • 合約輸入狀態
  • 後端快照投影狀態
  • UI 佈局狀態

不允許任何儲存同時擁有執行時真實狀態和佈局關注點。

4. 刪除活躍相容接縫

優先選擇刪除,而非「暫時同時支援兩者」。

典型的刪除項目:

  • 活躍編輯中的單數與複數 schema 相容性
  • 活躍桌面執行時中的瀏覽器或演示模擬
  • 主路徑中的已棄用節點類型
  • 重複的審查摘要
  • 多種起手或匯入格式

5. 在信任重構前加入評估器

每個實作節點應具有:

  • 一個針對正確性的本地輸出評估器
  • 一個針對合約安全性的下游就緒評估器
  • 一個重新啟動或重新連線路徑,該路徑從後端真實狀態(而非前端猜測)重新水合

失敗模式

投影偽裝成權威

症狀:UI 看似「唯讀」,但卻在本地悄悄組裝階段、圖形或供應商真實狀態。

修正方法:將該邏輯移至後端指令或查詢中,並將前端視為投影器。

相容接縫僵化

症狀:「暫時同時支援兩者」在熱路徑中停留數週,最終成為真正的架構。

修正方法:將相容性推向單向遷移邊緣,並附上明確的刪除日期,或立即將其刪除。

無可檢視性的審批

症狀:人類可以批准他們無法檢查的工作,因為審查負載是部分或不完整,或是前端合成的。

修正方法:後端必須發出確切的審查負載;UI 僅渲染它。

不利於重播的啟動

症狀:重新啟動應用程式會改變可視狀態或失去關卡位置,因為前端快取了權威狀態。

修正方法:啟動必須是針對後端真實狀態的查詢加上事件重播,而非儲存重建。

識別標誌

若重新啟動應用程式在沒有任何新後端事件的情況下改變了可視執行時狀態,則權威狀態仍然分裂。

工作實例

前端擁有階段邏輯的 Tauri 工作流程編輯器

問題:

  • React 儲存擁有圖形、推斷階段狀態和正規化供應商層級。
  • 後端執行使用不同的合約,導致審查和重新啟動流程產生偏移。

重構路徑:

  1. 清查 UI 發明執行時真實狀態的所有位置。
  2. 將執行時互動收斂為指令、查詢和事件。
  3. 將供應商正規化和階段轉換移至後端指令之後。
  4. 從活躍編輯路徑中刪除起手格式聯合。
  5. 加入評估器關卡,使下游工作僅能從後端驗證的輸出開始進行。

成功條件:

  • 重新啟動時,UI 從後端快照加上事件重建相同的可視狀態。
  • 審批畫面渲染後端發出的審查負載,而非 React 重新組合。

分支指導

在可以清晰分離工作時進行分支:

  • 合約軌道:清查分裂的權威接縫,並定義指令、查詢和事件。
  • 刪除軌道:移除相容層、已棄用節點類型和起手格式聯合。
  • 驗證軌道:加入評估器關卡、重播測試和重新啟動或重新連線覆蓋。

將最終所有權決定保留在父軌道中,以便由一個角色決定後端真正擁有什麼。

品質關卡

  • UI 無法在本地偽造圖形、階段、供應商或關卡真實狀態。
  • 每個使用者操作都對應到一個指令、查詢或事件。
  • 執行時狀態在重新啟動與重新連線後,僅從後端真實狀態即可存活。
  • 審查與審批負載由後端發出,並由 UI 渲染。
  • 相容邏輯僅存在於遷移邊緣,而非活躍路徑中。
  • 下游執行在上游合約失敗時停止。
  • 確切的供應商 ID 和模型選擇在合約邊界是可見的。
  • 測試涵蓋重新啟動、重新連線、審批和評估器失敗路徑。

參考地圖

  • references/architecture-patterns.md — 後端擁有的工作流程合約模式與狀態所有權拆分。
  • references/windags-lessons.md — 來自真實分裂權威執行時遷移的具體教訓。

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

curiositech/windags-skills

Expert in 2000s-era music visualization (Milkdrop, AVS, Geiss) and modern WebGL implementations. Specializes in Butterchurn integration, Web Audio API AnalyserNode FFT data, GLSL shaders for audio-reactive visuals, and psychedelic generative art. Activate on "Milkdrop", "music visualization", "WebGL visualizer", "Butterchurn", "audio reactive", "FFT visualization", "spectrum analyzer". NOT for simple bar charts/waveforms (use basic canvas), video editing, or non-audio visuals.

curiositech/windags-skills

Expert legal research agent for finding and scraping expungement data state by state. Knows authoritative sources, URL patterns, Firecrawl configuration, and 2026 legal landscape.

curiositech/windags-skills

Expert in 3D computer vision labeling tools, workflows, and AI-assisted annotation for LiDAR, point clouds, and sensor fusion. Covers SAM4D/Point-SAM, human-in-the-loop architectures, and vertical-specific training strategies. Activate on '3D labeling', 'point cloud annotation', 'LiDAR labeling', 'SAM 3D', 'SAM4D', 'sensor fusion annotation', '3D bounding box', 'semantic segmentation point cloud'. NOT for 2D image labeling (use clip-aware-embeddings), general ML training (use ml-engineer), video annotation without 3D (use computer-vision-pipeline), or VLM prompt engineering (use prompt-engineer).

curiositech/windags-skills

Implement WCAG 2.2 AA/AAA compliance with automated testing, keyboard navigation, screen reader support, and focus management. Activate on: accessibility audit, WCAG compliance, keyboard navigation, screen reader, aria attributes, axe-core, focus trap. NOT for: design-level accessibility review (use design-accessibility-auditor), color contrast only (use css-in-js-architect).

curiositech/windags-skills

Time-blind friendly planning, executive function support, and daily structure for ADHD brains. Specializes in realistic time estimation, dopamine-aware task design, and building systems that actually work for neurodivergent minds.

curiositech/windags-skills

Designs digital experiences for ADHD brains using neuroscience research and UX principles. Expert in reducing cognitive load, time blindness solutions, dopamine-driven engagement, and compassionate design patterns. Activate on 'ADHD design', 'cognitive load', 'accessibility', 'neurodivergent UX', 'time blindness', 'dopamine-driven', 'executive function'. NOT for general accessibility (WCAG only), neurotypical UX design, or simple UI styling without ADHD context.

curiositech/windags-skills

>- Apply crisis decision-making research to agent routing, uncertainty triage, and coordination failure analysis in time-pressured systems. Use when diagnosing handoff failures, analytical paralysis, or expert judgment under incomplete information. NOT for routine coding, simple CRUD design, or static single-agent tasks with complete information.

curiositech/windags-skills

Extend and modify the admin dashboard, developer portal, and operations console. Use when adding new admin tabs, metrics, monitoring features, or internal tools. Activates for dashboard development, analytics, user management, and internal tooling.

curiositech/windags-skills

Conversation patterns and interaction protocols for multi-agent systems. Covers request/response, pub/sub, blackboard, delegation chains, debate, critique, consensus, fan-out/fan-in, supervisor-worker, and peer negotiation. Deep analysis of AutoGen conversation patterns, CrewAI delegation, LangGraph state passing, and FIPA-ACL performatives. Teaches how to design what agents say to each other and in what order. Activate on: "agent conversation", "agent protocol", "multi-agent debate", "agent delegation", "supervisor worker pattern", "agent voting", "consensus protocol", "fan-out fan-in", "agent negotiation", "blackboard pattern", "agent dialogue", "conversation topology", "agent handoff". NOT for: wire format or serialization (use agent-interchange-formats), orchestration infrastructure (use agentic-infrastructure-2026), single agent behavior (use agentic-patterns).

curiositech/windags-skills

Meta-agent for creating new custom agents, skills, and MCP integrations. Expert in agent design, MCP development, skill architecture, and rapid prototyping. Activate on 'create agent', 'new skill', 'MCP server', 'custom tool', 'agent design'. NOT for using existing agents (invoke them directly), general coding (use language-specific skills), or infrastructure setup (use deployment-engineer).

curiositech/windags-skills

AI-powered calendar management and agent-based scheduling coordination. Covers calendar APIs (Google Calendar, CalDAV/iCal), AI scheduling assistants (Reclaim, Clockwise, Motion, Cal.com), building custom calendar agents with MCP, multi-calendar merging, timezone management, focus block protection, meeting fatigue detection, and agent-to-agent meeting negotiation protocols. Activate on: "calendar agent", "AI scheduling", "calendar coordination", "meeting scheduling", "calendar API", "focus time protection", "calendar optimization", "Google Calendar MCP", "Reclaim", "Clockwise", "Motion", "Cal.com", "smart scheduling", "calendar-aware agent", "timezone scheduling", "agent negotiation meetings". NOT for: manual calendar UI component design (use form-validation-architect), project management scheduling or Gantt charts (use project-management-guru-adhd), general time-tracking or pomodoro apps (use adhd-daily-planner for time-awareness), building the agent itself from scratch (use agent-creator).

curiositech/windags-skills

Build and adopt production AI agent infrastructure in 2026. Covers framework selection (LangGraph, CrewAI, AutoGen, MCP), orchestration patterns, evaluation, observability, memory systems, and tool use. Also covers the SOCIAL dimension: how to sell agent infrastructure internally, change management, measuring ROI, building trust in autonomous systems, and scaling adoption across teams. Activate on: "agent infrastructure", "agent framework comparison", "which agent framework", "sell AI tools internally", "agent adoption", "agent observability", "agent evaluation", "MCP architecture", "agentic mesh", "enterprise AI agents", "AI change management", "agent ROI". NOT for: building specific agents (use ai-engineer), designing agent behavior patterns (use agentic-patterns), prompt tuning (use prompt-engineer).

curiositech/windags-skills

Fundamental patterns for effective agentic behavior. Teaches decomposition, tool orchestration, error recovery, context management, quality self-assessment, and knowing when to stop. Model-agnostic principles that make any agent more effective regardless of domain. Activate on: "how should I structure this agent", "agentic workflow", "agent patterns", "multi-step task", "tool orchestration", "/agentic-patterns", "decompose this", "agent best practices", "chain of actions", "when should the agent stop", "agent loop design". NOT for: creating agent infrastructure (use agent-creator), building DAGs (use windags-architect), specific tool implementation.

curiositech/windags-skills

Automated discovery and matching of agent skills for dynamic task routing and capability assessment

curiositech/windags-skills

Cryptographic security for agentic systems — zero-trust agent networking, signed message envelopes (JWS/JWE), capability-based security (ocaps), Merkle tree audit trails, WASM sandboxing, and formal verification. Covers CLI dev tool security, mTLS between agents, permission boundaries (least privilege for AI agents), and supply chain security for skills/plugins. Activate on: "agent security", "zero trust agents", "secure agent communication", "capability-based security", "ocap", "signed messages between agents", "agent audit trail", "sandbox agent execution", "agent permissions", "mTLS agents", "cryptographic verification", "agent supply chain", "OWASP agentic", "prove agent did X", "tamper-proof agent logs". NOT for: application-level SAST scanning (use security-auditor), network firewall rules (use infrastructure), SOC2/HIPAA compliance (organizational), or prompt injection defense (use prompt-engineer).

curiositech/windags-skills

Data structures and serialization formats for agent-to-agent communication. Covers message envelopes, structured output schemas, capability declarations, task handoff payloads, error/retry signaling, and context windows as data structures. Deep comparison of A2A protocol, MCP, OpenAI function calling, and LangChain message types. Teaches when to use rigid schemas vs free-form with validation, typed vs untyped, streaming vs batch. Activate on: "agent message format", "agent communication schema", "agent-to-agent protocol", "A2A protocol", "MCP message format", "structured output for agents", "agent interop", "interchange format", "agent serialization", "task handoff format", "capability declaration". NOT for: what agents say to each other (use agent-conversation-protocols), orchestration topology (use multi-agent-coordination), building agent infrastructure (use agentic-infrastructure-2026).

curiositech/windags-skills

Logic-based agent programming language implementing BDI architecture for practical autonomous agent development

curiositech/windags-skills

>- Design AgentSpeak(L)-style BDI agents with context-guarded plans, selection functions, and intention stacks. Use for interruptible autonomy, agent policy, and multi-agent orchestration in dynamic environments. NOT for simple rule engines, static planners, or centralized workflows.

curiositech/windags-skills

Foundational concurrent computation model where actors communicate exclusively through asynchronous message passing

curiositech/windags-skills

license: Apache-2.0 NOT for unrelated tasks outside this domain.

相關技能