Communitygithub.com

点击路径审计

追踪每个用户可见按钮/触点经过完整状态变更序列,发现单个功能正常但相互抵消、产生错误最终状态或导致UI不一致的缺陷。适用于系统化调试未发现错误但用户反馈按钮失效,或任何涉及共享状态存储的重大重构之后。

点击路径审计 是什么?

点击路径审计(/click-path-audit)是一种行为流审计技能,旨在发现静态代码阅读难以捕捉的缺陷,例如状态交互副作用、顺序调用间的竞态条件以及处理函数彼此静默撤销的情况。该技能适用于各种AI代理平台(如Claude Code、Cursor、Codex),在系统化调试未发现错误但用户反馈按钮失效,或任何重大重构触及共享状态存储后使用。其工作流程包括:首先构建每个状态存储操作的副作用映射,然后逐一对每个交互触点执行六个检查步骤(识别处理函数、追踪所有函数调用序列、检查每个调用的状态读写与副作用、确认是否存在后续调用撤销前置状态变更、验证最终状态是否符合用户预期、检查异步调用的竞态条件)。该技能特别针对六大缺陷模式:顺序撤销、异步竞态、闭包过期、状态转换缺失、条件死路径以及useEffect干扰。通过规范的报告格式,该技能可显著提升复杂前端应用的可靠性。

兼容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/affaan-m/ECC/tree/main/skills/click-path-audit

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

/click-path-audit — 行为流审计

发现静态代码阅读遗漏的缺陷:状态交互副作用、顺序调用间的竞态条件、以及处理函数互相静默撤销。

此技能解决的问题

传统调试检查:

  • 函数是否存在?(缺少接线)
  • 是否会崩溃?(运行时错误)
  • 是否返回正确类型?(数据流)

但它不检查:

  • 最终UI状态是否与按钮标签所承诺的一致?
  • 函数B是否静默撤销了函数A刚刚完成的操作?
  • 共享状态(Zustand/Redux/上下文)是否存在副作用,抵消了预期操作?

真实案例:一个“新建邮件”按钮调用了setComposeMode(true)然后selectThread(null)。两个函数单独都能工作。但selectThread有一个副作用重置了composeMode: false。按钮毫无反应。系统化调试发现了54个缺陷——这一个却被遗漏了。


工作原理

针对目标区域中的每个交互触点:

1. 识别处理函数(onClick、onSubmit、onChange等)
2. 按顺序追踪处理函数中的每个函数调用
3. 针对每个函数调用:
   a. 它读取了什么状态?
   b. 它写入了什么状态?
   c. 它对共享状态是否有副作用?
   d. 它是否作为副作用重置/清除了任何状态?
4. 检查:是否有任何后续调用撤销了前置调用的状态变更?
5. 检查:最终状态是否与用户从按钮标签期望的一致?
6. 检查:是否存在竞态条件(异步调用以错误顺序解析)?

执行步骤

步骤1:映射状态存储

在审计任何触点之前,构建每个状态存储操作的副作用映射:

针对范围内的每个 Zustand store / React context:
  针对每个 action/setter:
    - 它设置了哪些字段?
    - 它是否作为副作用重置了其他字段?
    - 记录:actionName → {sets: [...], resets: [...]}

这是关键参考。如果不了解selectThread会重置composeMode,那么“新建邮件”的缺陷就是不可见的。

输出格式:

STORE: emailStore
  setComposeMode(bool) → sets: {composeMode}
  selectThread(thread|null) → sets: {selectedThread, selectedThreadId, messages, drafts, selectedDraft, summary} RESETS: {composeMode: false, composeData: null, redraftOpen: false}
  setDraftGenerating(bool) → sets: {draftGenerating}
  ...

危险重置(清除非自身所有状态的 action):
  selectThread → 重置 composeMode(由 setComposeMode 拥有)
  reset → 重置所有内容

步骤2:审计每个触点

针对目标区域内的每个按钮/开关/表单提交:

TOUCHPOINT: [按钮标签] in [组件:行号]
  HANDLER: onClick → {
    call 1: functionA() → sets {X: true}
    call 2: functionB() → sets {Y: null} RESETS {X: false}  ← 冲突
  }
  EXPECTED: 用户看到 [按钮标签所承诺内容的描述]
  ACTUAL: X 为 false,因为 functionB 重置了它
  VERDICT: 缺陷 — [描述]

检查以下每种缺陷模式:

模式1:顺序撤销

handler() {
  setState_A(true)     // 设置 X = true
  setState_B(null)     // 副作用:重置 X = false
}
// 结果:X 为 false。第一个调用毫无意义。

模式2:异步竞态

handler() {
  fetchA().then(() => setState({ loading: false }))
  fetchB().then(() => setState({ loading: true }))
}
// 结果:最终 loading 状态取决于哪个先解析

模式3:闭包过期

const [count, setCount] = useState(0)
const handler = useCallback(() => {
  setCount(count + 1)  // 捕获了过期的 count
  setCount(count + 1)  // 同样的过期 count — 增加了1,而不是2
}, [count])

模式4:状态转换缺失

// 按钮显示“保存”但处理函数只验证,从未实际保存
// 按钮显示“删除”但处理函数设置了一个标志而未调用 API
// 按钮显示“发送”但 API 端点已被移除或损坏

模式5:条件死路径

handler() {
  if (someState) {        // 此时 someState 始终为 false
    doTheActualThing()    // 永远不会到达
  }
}

模式6:useEffect干扰

// 按钮设置 stateX = true
// 一个 useEffect 监视 stateX 并将其重置为 false
// 用户看不到任何变化

步骤3:报告

对于每个发现的缺陷:

CLICK-PATH-NNN: [严重性: CRITICAL/HIGH/MEDIUM/LOW]
  Touchpoint: [按钮标签] in [文件:行号]
  Pattern: [顺序撤销 / 异步竞态 / 闭包过期 / 缺失转换 / 死路径 / useEffect干扰]
  Handler: [函数名或内联]
  Trace:
    1. [调用] → sets {字段: 值}
    2. [调用] → RESETS {字段: 值}  ← 冲突
  Expected: [用户期望的结果]
  Actual: [实际发生的结果]
  Fix: [具体修复方案]

范围控制

此审计成本较高。请合理确定范围:

  • 全应用审计: 发布时或重大重构后使用。按页面启动并行代理。
  • 单页面审计: 构建新页面后或用户报告按钮失效后使用。
  • 存储聚焦审计: 修改某个 Zustand store 后使用——审计所有使用变更操作的消费者。

推荐的全应用代理分工:

Agent 1: 映射所有状态存储(步骤1)——这是其他所有代理的共享上下文
Agent 2: 仪表盘(任务、笔记、日志、想法)
Agent 3: 聊天(DanteChatColumn、JustChatPage)
Agent 4: 邮件(ThreadList、DraftArea、EmailsPage)
Agent 5: 项目(ProjectsPage、ProjectOverviewTab、NewProjectWizard)
Agent 6: CRM(所有子选项卡)
Agent 7: 个人信息、设置、保险库、通知
Agent 8: 管理套件(所有页面)

Agent 1 必须首先完成。其输出是其他所有代理的输入。


何时使用

  • 系统化调试发现“无缺陷”但用户报告UI失效时
  • 修改任何 Zustand store 操作后(检查所有调用方)
  • 任何涉及共享状态的重构之后
  • 发布前,对关键用户流程
  • 当按钮“什么都不做”时——这是解决该问题的利器

何时不使用

  • 针对 API 级别缺陷(错误的响应结构、缺失端点)——应使用 systematic-debugging
  • 针对样式/布局问题——视觉检查
  • 针对性能问题——性能分析工具

与其他技能的集成

  • 在 /superpowers:systematic-debugging 之后运行(该技能会找到另外54种缺陷类型)
  • 在 /superpowers:verification-before-completion 之前运行(该技能用于验证修复是否有效)
  • 输出反馈给 /superpowers:test-driven-development ——此处发现的每个缺陷都应编写相应的测试

示例:激发此技能的缺陷

ThreadList.tsx “新建邮件”按钮:

onClick={() => {
  useEmailStore.getState().setComposeMode(true)   // ✓ 设置 composeMode = true
  useEmailStore.getState().selectThread(null)      // ✗ 重置 composeMode = false
}}

Store 定义:

selectThread: (thread) => set({
  selectedThread: thread,
  selectedThreadId: thread?.id ?? null,
  messages: [],
  drafts: [],
  selectedDraft: null,
  summary: null,
  composeMode: false,     // ← 这个静默重置“杀死了”按钮
  composeData: null,
  redraftOpen: false,
})

系统化调试错过了它 因为:

  • 按钮有一个 onClick 处理函数(未死亡)
  • 两个函数都存在(未缺少接线)
  • 两个函数都不崩溃(无运行时错误)
  • 数据类型正确(无类型不匹配)

点击路径审计捕获了它 因为:

  • 步骤1 映射出 selectThread 重置了 composeMode
  • 步骤2 追踪处理函数:调用1设置 true,调用2重置 false
  • 判定:顺序撤销——最终状态与按钮意图相矛盾

Individual skills in this repo

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

accessibility

Design, implement, and audit inclusive digital products using WCAG 2.2 Level AA. Use when building or auditing UI that must meet WCAG 2.2 Level AA, or when reviewing a change for keyboard, contrast, or screen-reader support.

affaan-m/content-engine

Create platform-native content systems for X, LinkedIn, TikTok, YouTube, newsletters, and repurposed multi-platform campaigns. Use when the user wants social posts, threads, scripts, content calendars, or one source asset adapted cleanly across platforms.

affaan-m/ECC

Multi-platform content distribution across X, LinkedIn, Threads, and Bluesky. Adapts content per platform using content-engine patterns. Never posts identical content cross-platform. Use when the user wants to distribute content across social platforms.

affaan-m/fal-ai-media

Unified media generation via fal.ai MCP — image, video, and audio. Covers text-to-image (Nano Banana), text/image-to-video (Seedance, Kling, Veo 3), text-to-speech (CSM-1B), and video-to-audio (ThinkSound). Use when the user wants to generate images, videos, or audio with AI.

affaan-m/manim-video

日本語翻訳:このファイルは manim-video 用の日本語翻訳が必要です

affaan-m/remotion-video-creation

Remotion のベストプラクティス - React で動画を作成する。3D、アニメーション、音声、字幕、チャート、トランジションなどをカバーするドメイン固有の29のルール。

affaan-m/video-editing

AI-assisted video editing workflows for cutting, structuring, and augmenting real footage. Covers the full pipeline from raw capture through FFmpeg, Remotion, ElevenLabs, fal.ai, and final polish in Descript or CapCut. Use when the user wants to edit video, cut footage, create vlogs, or build video content.

agent-architecture-audit

Full-stack diagnostic for agent and LLM applications. Audits the 12-layer agent stack for wrapper regression, memory pollution, tool discipline failures, hidden repair loops, and rendering corruption. Produces severity-ranked findings with code-first fixes. Essential for developers building agent applications, autonomous loops, or any LLM-powered feature. Use when an agent or LLM feature misbehaves and the failing layer is unknown, or before shipping an agent stack.

agent-eval

Head-to-head comparison of coding agents (Claude Code, Aider, Codex, etc.) on custom tasks with pass rate, cost, time, and consistency metrics. Use when choosing between coding agents, or when a change to an agent setup needs measured pass rate, cost, and time rather than an impression.

agent-harness-construction

Design and optimize AI agent action spaces, tool definitions, and observation formatting for higher completion rates. Use when defining or revising an agent

agentic-engineering

Operate as an agentic engineer using eval-first execution, decomposition, and cost-aware model routing. Use when planning or executing engineering work that agents will carry out end to end.

agentic-os

Build persistent multi-agent operating systems on Claude Code. Covers kernel architecture, specialist agents, slash commands, file-based memory, scheduled automation, and state management without external databases. Use when building a persistent multi-agent system on Claude Code with its own memory, commands, and scheduling.

agent-introspection-debugging

Structured self-debugging workflow for AI agent failures using capture, diagnosis, contained recovery, and introspection reports. Use when an agent run fails and you need a reproducible diagnosis instead of a retry.

agent-payment-x402

Add x402 payment execution to AI agents with per-task budgets, spending controls, and non-custodial wallets. Supports Base through agentwallet-sdk and X Layer through OKX Payments / OKX Agent Payments Protocol. Use when an agent must pay for something itself and needs per-task budgets, spending controls, and a non-custodial wallet.

agent-self-evaluation

Use after completing any non-trivial task. The agent self-rates its output on 5 axes — accuracy, completeness, clarity, actionability, conciseness — with concrete evidence per criterion. Produces a structured 1-5 scorecard with specific improvement suggestions.

agent-sort

Build an evidence-backed ECC install plan for a specific repo by sorting skills, commands, rules, hooks, and extras into DAILY vs LIBRARY buckets using parallel repo-aware review passes. Use when ECC should be trimmed to what a project actually needs instead of loading the full bundle.

ai-first-engineering

Engineering operating model for teams where AI agents generate a large share of implementation output. Use when setting team process, review gates, or ownership rules for a codebase largely written by agents.

ai-regression-testing

Regression testing strategies for AI-assisted development. Sandbox-mode API testing without database dependencies, automated bug-check workflows, and patterns to catch AI blind spots where the same model writes and reviews code. Use when adding regression coverage to AI-assisted code, or when the same model both wrote and reviewed a change.

android-clean-architecture

Clean Architecture patterns for Android and Kotlin Multiplatform projects — module structure, dependency rules, UseCases, Repositories, and data layer patterns. Use when structuring modules, layers, or data flow in an Android or KMP project.

angular-developer

Generates Angular code and provides architectural guidance. Trigger when creating projects, components, or services, or for best practices on reactivity (signals, linkedSignal, resource), forms, dependency injection, routing, SSR, accessibility (ARIA), animations, styling (component styles, Tailwind CSS), testing, or CLI tooling.

相关技能