← 返回 Skills 市场
1011
总下载
0
收藏
6
当前安装
1
版本数
在 OpenClaw 中安装
/install ui-debug-methodology
功能描述
UI/前端问题调试方法论。当遇到 CSS、布局、组件行为等 UI 问题时,强制执行"先观察后动手"的调试流程,避免盲目尝试。
使用说明 (SKILL.md)
UI 问题调试方法论
核心原则:先理解机制,后动手修改。
当 UI 行为不符合预期时,禁止立即修改代码。必须先完成以下调试流程。
触发条件
当遇到以下情况时,必须激活本 skill 的调试流程:
- UI 行为不符合预期
- CSS/样式不生效
- 组件交互有问题(拖拽、点击、hover 等)
- 布局错乱
- 第一次尝试修复失败后
强制流程
┌─────────────────────────────────────────────────────────────┐
│ UI 问题调试流程 │
├─────────────────────────────────────────────────────────────┤
│ │
│ 1. 观察现象 用 DevTools 检查实际 DOM 和样式 │
│ │ │
│ ▼ │
│ 2. 理解机制 搞清楚组件/CSS 的工作原理 │
│ │ │
│ ▼ │
│ 3. 定位根因 找到真正控制行为的代码/配置 │
│ │ │
│ ▼ │
│ 4. 最小修复 只改必要的部分 │
│ │ │
│ ▼ │
│ 5. 验证 测试所有场景 │
│ │ │
│ └──── 失败 ────▶ 回到步骤 1,不要继续打补丁 │
│ │
└─────────────────────────────────────────────────────────────┘
Step 1: 观察现象
必须使用 DevTools 或 Playwright,而不是猜测。
检查清单
| 检查项 | 方法 |
|---|---|
| 实际的 DOM 结构 | Elements 面板 |
| Computed styles | 查看 width/height/min-width/max-width 等 |
| 样式来源 | 看是哪个 CSS 规则在生效 |
| 是否有覆盖 | 查看被划掉的样式 |
| 布局模式 | table-layout / display / flex / grid |
| 事件是否触发 | Console 加 log 或 breakpoint |
使用 Playwright 检查(AI Agent 执行)
当作为 AI Agent 调试时,使用 Playwright 获取运行时信息:
// 获取元素的 computed style
const style = await page.$eval('selector', el => {
const computed = window.getComputedStyle(el);
return {
width: computed.width,
minWidth: computed.minWidth,
maxWidth: computed.maxWidth,
display: computed.display,
position: computed.position,
tableLayout: computed.tableLayout
};
});
// 获取实际 DOM 结构
const html = await page.$eval('selector', el => el.outerHTML);
// 检查元素是否可见
const isVisible = await page.isVisible('selector');
// 截图对比
await page.screenshot({ path: 'debug-before.png' });
关键:先拿到实际数据,再做判断。不要基于代码猜测运行时状态。
Step 2: 理解机制
在动手前,必须能回答以下问题:
- 这个组件/CSS 属性的工作原理是什么?
- 哪些因素会影响它的行为?
- 我要修改的代码,在整个流程中扮演什么角色?
常见机制陷阱
| 场景 | 陷阱 | 真相 |
|---|---|---|
| Ant Design Table 列宽 | 以为 \x3Cth> 的 width 控制列宽 |
实际由 \x3Ccolgroup> + scroll.x 控制 |
scroll.x: 'max-content' |
以为只是让表格可横向滚动 | 实际让浏览器忽略 width,根据内容计算 |
| Flexbox 子元素宽度 | 设置了 width 但不生效 | 需要同时设置 flex-shrink: 0 |
CSS position: absolute |
以为相对于父元素 | 实际相对于最近的 position: relative 祖先 |
transform |
只是视觉变换 | 会影响 position: fixed 子元素的定位 |
z-index 不生效 |
以为值越大越靠前 | 需要在同一个 stacking context 中比较 |
overflow: hidden |
只影响自身 | 会创建新的 BFC,影响子元素布局 |
如果不熟悉机制
- 先查官方文档(MDN、组件库文档)
- 搜索 "X not working" / "X width ignored" 等关键词
- 检查组件库源码
- 创建最小复现 demo
Step 3: 定位根因
问自己:是我的代码问题,还是框架/机制问题?
二分法排除
- 移除可疑代码,看问题是否消失
- 创建最小复现,逐步添加代码直到问题出现
- 检查是否有其他 CSS/JS 在干扰
常见根因类型
| 类型 | 示例 | 修复方向 |
|---|---|---|
| 配置问题 | scroll.x: 'max-content' 导致列宽失效 |
修改配置 |
| CSS 优先级 | 全局样式覆盖了组件样式 | 提高优先级或改选择器 |
| 组件 API 误用 | 用错了 prop 或 callback 签名 | 查文档,改用法 |
| 机制不匹配 | 想用 CSS 控制,但实际由 JS 控制 | 改用正确的控制方式 |
| 第三方库限制 | 库不支持这种用法 | 换方案或 fork |
Step 4: 最小修复
只改必要的部分,不引入新复杂度。
原则
- 能用原生实现就不引入库
- 能改配置就不改代码
- 能改一处就不改多处
- 改完能解释清楚为什么这样改
反模式(禁止)
| 反模式 | 问题 |
|---|---|
| 引入新库解决小问题 | 增加依赖,可能带来新问题 |
到处加 !important |
掩盖问题,后续更难维护 |
| 在多个地方加补丁 | 说明没找到根因 |
| 改了生效但不知道为什么 | 下次还会踩坑 |
用 as any / @ts-ignore 绕过类型错误 |
隐藏真实问题 |
Step 5: 验证
测试所有场景,不只是出问题的那个。
验证清单
- 原问题场景修复
- 相关场景没有回归
- 边界情况(空数据、超长内容、极小/极大值)
- 不同浏览器(如果需要)
- 响应式布局(如果需要)
失败后的处理
如果验证失败,回到 Step 1 重新观察。
禁止:
- 继续在当前方向打补丁
- 猜测 "可能是这个原因"
- 没观察就尝试下一个修复
案例:Ant Design Table 可拖拽列宽
❌ 错误路径(实际发生的)
问题:拖拽列宽时,某些列往左拖不动
尝试 1:用 react-resizable 库 → 失败
尝试 2:设置 minWidth/maxWidth → 失败
尝试 3:改 CSS table-layout → 失败
尝试 4:改 transform → 失败
...(反复折腾 N 次)
最终:改 scroll.x → 成功
✅ 正确路径(应该这样做)
1. 观察:DevTools 检查 \x3Cth> 的 computed width
→ 发现 width 确实在变,但视觉没变
2. 理解:搜索 "ant design table column width not working"
→ 发现 scroll.x: 'max-content' 会让浏览器忽略 width
3. 定位:scroll.x 是根因
4. 修复:scroll.x 改成列宽总和
5. 验证:所有列都能正常拖拽
总耗时:10 分钟(而不是 N 小时)
禁止事项
- 禁止不观察就动手改代码
- 禁止不理解机制就引入新库
- 禁止修复失败后继续猜测打补丁
- 禁止改了生效但说不清为什么
- 禁止跳过验证步骤直接提交
速查表
UI 问题 → DevTools 观察 → 理解机制 → 定位根因 → 最小修复 → 验证
↑ |
└────────── 失败则回到这里 ──────────────┘
安全使用建议
This skill is a coherent debugging methodology, but before using it confirm: (1) your agent runtime actually has Playwright or an equivalent browser automation tool available (the SKILL.md assumes it but does not declare it); (2) the agent is allowed to execute Playwright and write files (screenshots like 'debug-before.png') in the environment; (3) screenshots/DOM captures may contain sensitive data — decide where such artifacts are stored/transmitted and who can access them; (4) if you don't want the agent to run tooling autonomously, restrict the skill's invocation or test it in an isolated/dev environment first. If any of these are unacceptable, ask the skill author to declare required binaries and to add explicit data-handling rules.
功能分析
Type: OpenClaw Skill
Name: ui-debug-methodology
Version: 1.0.0
The skill provides a structured methodology for an AI agent to debug UI/frontend issues. All instructions in SKILL.md, including the embedded Playwright JavaScript code snippets, are directly related to observing DOM, styles, and taking screenshots within a browser context for debugging purposes. There is no evidence of malicious intent, data exfiltration, unauthorized command execution, or harmful prompt injection attempts. The skill aims to guide the agent through a logical debugging process.
能力评估
Purpose & Capability
The skill's name and description (UI/frontend debugging methodology) match the SKILL.md instructions. However, the document explicitly tells an AI agent to use Playwright to collect runtime data; the skill declares no required binaries or install steps. That mismatch is explainable (methodology can assume a debugging runtime) but worth noting because Playwright is not declared as a requirement.
Instruction Scope
Instructions stay within the stated purpose: observe DOM/state, understand mechanisms, isolate root cause, make minimal fixes, and verify. The included Playwright snippet shows how an agent can collect computed styles, outerHTML, visibility, and take screenshots — all relevant to debugging. The only scope concern is that screenshots and DOM captures can contain sensitive data; the instructions do not place restrictions on handling or transmitting collected artifacts.
Install Mechanism
There is no install spec (instruction-only skill), so nothing is written to disk by the skill itself. This is low-risk from an install mechanism perspective.
Credentials
The skill requests no environment variables or credentials, which is appropriate. But it implicitly expects runtime capabilities: a browser/Playwright environment and filesystem access (it saves screenshots to 'debug-before.png'). Confirm these capabilities exist and are acceptable in your agent environment before use.
Persistence & Privilege
always is false and the skill does not request persistent presence or modify other skills/configuration. Autonomous invocation is allowed (platform default) but not in itself a red flag here.
如何使用
- 确保已安装 OpenClaw(本地或 Docker 部署)
- 在对话框中输入安装命令:
/install ui-debug-methodology - 安装完成后,直接呼叫该 Skill 的名称或使用
/ui-debug-methodology触发 - 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.0
- Initial release of UI/front-end debugging methodology.
- Introduces a strict "observe before you code" workflow for CSS, layout, and component issues.
- Provides step-by-step processes: Observe, Understand Mechanism, Locate Root Cause, Minimal Fix, and Verify.
- Includes common pitfalls, checklists, and real-world case studies for guidance.
- Aims to reduce blind trial-and-error and improve debugging efficiency for all frontend projects.
元数据
常见问题
ui-debug-methodology 是什么?
UI/前端问题调试方法论。当遇到 CSS、布局、组件行为等 UI 问题时,强制执行"先观察后动手"的调试流程,避免盲目尝试。 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 1011 次。
如何安装 ui-debug-methodology?
在 OpenClaw 或 Claude Code 对话框中运行命令「/install ui-debug-methodology」即可一键安装,无需额外配置。
ui-debug-methodology 是免费的吗?
是的,ui-debug-methodology 完全免费(开源免费),可自由下载、安装和使用。
ui-debug-methodology 支持哪些平台?
ui-debug-methodology 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。
谁开发了 ui-debug-methodology?
由 chrsh44e(@chrsh44e)开发并维护,当前版本 v1.0.0。
推荐 Skills