前端诊断
- 作者仓库星标 6
- 作者更新于 实时读取
- 作者仓库 deepin-skills
- 领域
- 工程开发
- 兼容 Agent
-
- Claude Code
- Cursor
- Cline
- Codex
- Windsurf
- Gemini CLI
- +20
- 信任分
- 88 / 100 · 社区维护
- 作者 / 版本 / 许可
- @re2zero · 未声明 license
- Token 消耗评级
- 低消耗
- 接入复杂程度
- 需简单配置
- 是否需要外部 API Key
- 不需要
- 兼容的系统
- 未声明(默认跨平台)
- 底层运行要求
- 无特殊要求
- 文件与系统权限
-
- 只读
- 允许写入 / 修改
- Shell 执行
- 网络行为
- 仅限本地
- 安装命令数
- 26 条
档案由构建时根据 SKILL.md 与安装命令自动衍生,可能与作者实际意图存在差异。
需要注意: 未限定 allowed-tools,默认拥有全部工具权限。
---
name: qt-cpp-bug-fixer
description: Use when encountering compilation errors, runtime crashes, memory leaks, UI issues, or threading…
category: 工程开发
runtime: 无特殊运行时
---
# qt-cpp-bug-fixer 输出预览
## PART A: 任务判断
- 适用问题:代码实现、重构、调试或代码审查。
- 输入要求:目标材料、限制条件、期望输出和验收方式。
- 证据边界:围绕“Overview / When to Use / Core Pattern”读取原文规则,不把推断写成作者承诺。
## PART B: 执行结果
- **01** 任务判断:确认你的需求是否属于代码实现、重构、调试或代码审查,并标出输入、限制和预期结果。
- **02** 执行计划:优先按“Overview / When to Use / Core Pattern”拆成步骤,说明每一步会读取什么、修改什么、产出什么。
- **03** 交付结果:给出可复制的命令、文件改动、检查清单或内容草稿,并说明如何继续迭代。
- **04** 风险边界:结合 读取文件、写入/修改文件、执行终端命令、主要在本地完成、通常不需要额外 API Key 给出执行前确认项。
## Running Rules
- 读取文件、写入/修改文件、执行终端命令;主要在本地完成;通常不需要额外 API Key。
- 先小样例验证,再放大到真实任务。
- 交付时同时给结果、检查口径和下一步迭代建议。 原文没有稳定的斜杠命令要求。安装验证后通常全局生效,直接在对话里点名这个 Skill 并描述任务即可。
告诉 Agent 目标文件或材料、期望结果、不可改范围、是否允许联网或执行命令。本 Skill 的权限画像是:读取文件、写入/修改文件、执行终端命令。
先用一个小任务确认它会围绕“Overview / When to Use / Core Pattern”工作;涉及文件或命令时,先看 diff、日志、预览或测试结果。
检查最终产物是否包含明确结果、必要证据和下一步动作;如果输出泛泛而谈,就补充输入、边界和验收标准后重跑。
---
name: qt-cpp-bug-fixer
description: Use when encountering compilation errors, runtime crashes, memory leaks, UI issues, or threading…
category: 工程开发
source: re2zero/deepin-skills
---
# qt-cpp-bug-fixer
## 什么时候使用
- qt-cpp-bug-fixer 是一个工程开发方向的技能,扩展 Agent 在写代码、做 review、跑测试这类场景下的能力 适合处理工程开发场景下的代码实现、调试、重构、测试或代码审查,核心价值是把输入、判断、执行、验证和交付边界…
- 面向代码实现、重构、调试或代码审查,优先处理能明确输入、步骤和验收标准的工作。
## 需要提供什么
- 目标材料、目录范围、期望结果和不可改动内容。
- 是否允许联网、执行命令、读写文件或调用外部服务。
## 执行规则
- 围绕「Overview / When to Use / Core Pattern」组织步骤,不把推断写成作者事实。
- 读取文件、写入/修改文件、执行终端命令;主要在本地完成;通常不需要额外 API Key。
- 先跑小样例,确认结果可检查后再扩大任务范围。
## 输出要求
- 给出最终产物、关键证据、验证方式和下一步动作。
- 信息不足时标记 unknown,不编造命令、平台或依赖。 作者原文负责流程事实;仓库文件负责来源和命令;流狐只补充适用场景、限制和质量判断。
skill "qt-cpp-bug-fixer" {
输入层 -> 用户目标 + 目标文件 + 禁止范围 + 验收标准
上下文层 -> Overview / When to Use / Core Pattern
规则层 -> SKILL.md 触发条件 / 执行顺序 / 输出格式
运行层 -> 无特殊运行时 | 读取文件、写入/修改文件、执行终端命令 | 主要在本地完成
安全层 -> 通常不需要额外 API Key + 小任务验证 + diff / 日志复核
输出层 -> 可复制结果 + 检查清单 + 下一步迭代
} Qt C++ Bug Fixer
Overview
Diagnose and fix Qt C++ bugs with minimal, Qt-style changes. Iron Rule: Fix ONLY the reported issue. No extra refactoring, no "while I'm here" improvements.
When to Use
Compilation Errors: undefined reference to 'vtable', missing Q_OBJECT, MOC errors, circular includes, CMakeLists.txt/.pro issues
Runtime Crashes: Segmentation faults, null pointer dereferences, pure virtual calls
Memory Issues: new without delete, incorrect parent-child relationships, leaks
UI Problems: Widgets not displaying, layout failures, signal-slot not working, unresponsive controls
Threading: Cross-thread UI crashes, thread affinity, blocking UI thread
Do NOT use when: Intentionally refactoring, adding features (use TDD), or performance optimization
Core Pattern
// ❌ WRONG: Refactoring while fixing
void MyWidget::processData()
{
if (m_processor) {
auto dataProcessor = m_processor; // UNNECESSARY rename
QList<int> items = dataProcessor->getItems(); // UNNECESSARY STL→Qt
qDebug() << "Processing" << items.size(); // UNNECESSARY logging
}
}
// ✅ CORRECT: Only the fix
void MyWidget::processData()
{
if (m_processor) { // Fix: Added null check
m_processor->process();
}
}
// ❌ WRONG: External smart pointers
#include <memory>
std::unique_ptr<DataProcessor> m_processor;
// ✅ CORRECT: Qt parent-child ownership
DataProcessor *m_processor = new DataProcessor(this); // Parent handles deletion
Quick Reference
| Bug Type | Root Cause | Minimal Fix |
|---|---|---|
undefined reference to 'vtable' |
Missing Q_OBJECT macro |
Uncomment/add Q_OBJECT in header |
moc file not generated |
Header not in CMakeLists.txt/.pro | Add header to build files |
| Segfault on nullptr | No null check before dereferencing | Add if (ptr) before use |
| Memory leak | new without parent ownership |
Add parent to new or use deleteLater() |
| Signal not firing | Connection broken or wrong signature | Check connect() syntax and lifetime |
| Cross-thread UI crash | Direct UI manipulation from worker | Use QMetaObject::invokeMethod or signal-slot |
Implementation
1. Diagnostic Phase
Read error carefully: Compiler error → find line number; Runtime crash → read backtrace; UI issue → note specific behavior
Locate problematic code: Use @file:line notation, read context (class definition, includes, parent), check related files
Check Qt context: Does class inherit QObject? Is Q_OBJECT present? Are parent-child relationships correct? Are signals/slots connected?
2. Hypothesis and Verification
Generate 1-2 root causes: Focus on error type (MOC/config, memory/null, signals/layout, thread affinity)
Verify hypothesis: Check code - don't assume. MOC errors always involve Q_OBJECT and meta-object system
3. Generate Minimal Fix
Fix ONLY the identified issue: ONE problem = ONE fix. No variable renames, no style cleanup, no optimizations
Explain WHY: Root cause, not symptom. Qt-specific mechanics (MOC, parent-child, signal-slot)
Explain HOW: Principle behind change. Why it solves root cause
Regression testing: Compile (cmake --build . or make), suggest specific verification steps, run tests if applicable
4. Configuration File Fixes
CMakeLists.txt:
qt_add_executable(MyApp
main.cpp
mywidget.h # MUST include header with Q_OBJECT
mywidget.cpp
)
.pro file:
HEADERS += mywidget.h # Headers with Q_OBJECT must be listed
SOURCES += mywidget.cpp
Common Mistakes
| Mistake | Why Wrong | Correct |
|---|---|---|
| Renaming variables while fixing | Violates minimal change principle | Keep existing names |
| "Upgrading" SIGNAL/SLOT to lambda | Unnecessary change, breaks code | Fix only broken connection |
| Converting STL to Qt containers | Unrelated to bug | Fix only what causes crash |
| Adding logging "for debugging" | Extra code not needed | Fix root cause directly |
| Adding null checks everywhere | Masks real problem | Add only where crash occurs |
| Refactoring while fixing | Scope creep, introduces bugs | ONE fix per bug report |
Rationalization Table
| Excuse | Reality |
|---|---|
| "This variable name is confusing, I'll rename it" | Variable names don't cause crashes. Fix the crash. |
| "While I'm here, let me upgrade to modern Qt syntax" | Technical debt is not a bug. Fix the bug. |
| "This cleanup makes the code clearer" | Clarity improvements are refactoring, not bug fixing. |
| "The old SIGNAL/SLOT macros are deprecated" | Deprecated ≠ broken. Fix only what's broken. |
| "I'm adding a safeguard, it's defensive programming" | Safeguards without justification are extra code. Fix root cause. |
| "This refactoring is minimal and obvious" | Any change beyond the fix is NOT minimal. |
| "I'll improve the design while fixing it" | Design improvements are separate tasks. Fix the bug. |
| "It's about quality, not just functionality" | Quality bug fixes focus on minimal, surgical changes. |
Red Flags - STOP and Start Over
STOP immediately if you think or say ANY of these:
- "While I'm fixing this, I'll also..."
- "This is a good opportunity to clean up..."
- "The old style should be modernized..."
- "I'll add a safeguard/precaution..."
- "This variable name is confusing, better rename it..."
- "Let me upgrade to the latest Qt API..."
- "This design could be improved..."
- "I'll make it more robust/defensive..."
- "This code is messy, let me organize it..."
ALL mean: You're doing MORE than fixing the bug. Stop. Delete extra changes. Fix ONLY the reported issue.
Qt-Specific Anti-Patterns
Avoid External Smart Pointers:
// ❌ std::unique_ptr
std::unique_ptr<QWidget> m_widget;
// ✅ Qt parent-child
QWidget *m_widget = new QWidget(this);
Thread-Aware Connections:
// ❌ Wrong affinity assumption
workerThread->start();
worker->doWork(); // Might crash
// ✅ Qt 5 explicit type
connect(worker, &Worker::finished, this, [this]() {}, Qt::QueuedConnection);
Qt Blocking Helpers:
// ❌ Manual locks
QMutexLocker locker(&m_mutex);
// ✅ Qt's QSignalBlocker
QSignalBlocker blocker(this); // Auto-unblocks on scope exit
Memory Management:
// ❌ Manual delete
MyWidget *w = new MyWidget();
delete w;
// ✅ Parent-child system
MyWidget *w = new MyWidget(this); // Parent deletes on destruction
Backward Compatibility
CRITICAL: Verify fix doesn't break existing connections:
- Check all
connect()calls to/from modified object - Verify object lifetime doesn't break parents/children
- Don't change signal/slot signatures unless that's the bug
- Don't remove connections unless causing the issue
The Iron Law
Fixing bugs is NOT an excuse for refactoring.
Every change beyond the minimal fix introduces new risk, wastes user's time, violates the contract of "bug fix."
When in doubt: Ask yourself "Would this change be justified if I only said I was fixing the bug, not 'cleaning up'?"
If NO → Delete the change. Fix ONLY the bug.
No exceptions:
- Not for "obvious" improvements
- Not for "technical debt" reduction
- Not for "best practices" alignment
- Not for "making it clearer"
- Not for "while I'm here"
- Minimal fix means MINIMAL
先判断是否适合
作者设计意图
作者的方法与取舍
边界和复核