bug-fix

bug-fix is a cursor rule for Cursor from Mr-chen-05/rules-2.1-optimized. It costs 0 tokens per session (2,365 once invoked), scanned A, original, MIT.

A set of Chinese rules for fixing software bugs from the initial report through a pull request. It covers recording the environment, reproducing the issue, writing a failing test, analysing the cause, applying the fix, and verifying it.

In plain words
What is it for?
Use it when handling a bug: create a detailed issue, make a fix branch, reproduce the failure, add a test, identify the root cause, implement the change, and verify the result.
Why use it?
It turns an unclear bug report into a repeatable investigation and gives the fix evidence that the problem was reproduced and resolved.

Cursor rule for Cursor

Written for Cursor: a Cursor rule (.mdc).

Good fit Use it when handling a bug: create a detailed issue, make a fix branch, reproduce the failure, add a test, identify the root cause, implement the change, and verify the result.

Compare 6 cursor rules from other repositories ↓
Install with agentmods
npx agentmods add rules/mr-chen-05/rules-2.1-optimized/bug-fix
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Clone the repo
git clone --depth 1 https://github.com/Mr-chen-05/rules-2.1-optimized

Made for: Cursor.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for bug-fix

README.md
[![agentmods](https://agentmods.dev/badge/rules/mr-chen-05/rules-2.1-optimized/bug-fix/github.svg)](https://agentmods.dev/rules/mr-chen-05/rules-2.1-optimized/bug-fix)
Your own site
<a href="https://agentmods.dev/rules/mr-chen-05/rules-2.1-optimized/bug-fix"><img src="https://agentmods.dev/badge/rules/mr-chen-05/rules-2.1-optimized/bug-fix/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for bug-fix

Your own site · 80×15
<a href="https://agentmods.dev/rules/mr-chen-05/rules-2.1-optimized/bug-fix"><img src="https://agentmods.dev/badge/rules/mr-chen-05/rules-2.1-optimized/bug-fix.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 2,365 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00000 $0.02365
Opus 5.5 $0.00000 $0.00946
Sonnet 5.5 $0.00000 $0.00473
Haiku 4.5 $0.00000 $0.00236

Measured 1mo ago against content hash b56efabe5874, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

bug-fix scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 1mo ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

project-rules/bug-fix.mdc · 342 lines

How it starts

The opening of the file, as written. The whole thing — 342 lines — stays where its author put it; the contents beside it link to each section on GitHub.

🐛 Bug Fix Workflow - Bug修复工作流

从问题创建到拉取请求的完整Bug修复工作流程。

🚀 Commands - 命令

  • /bug-fix - 启动Bug修复工作流
  • /reproduce-bug - 重现Bug
  • /root-cause - 根因分析
  • /fix-verify - 修复验证

📋 Process - 修复流程

🔍 Before Starting - 开始前准备

1. GitHub Issue Creation - 创建GitHub问题
**Bug标题**: [组件/模块] 简短描述性标题

**环境信息**:
- 操作系统: Windows 11 / macOS 13 / Ubuntu 22.04
- 浏览器: Chrome 120 / Firefox 121 / Safari 17
- 应用版本: v2.1.0
- Node.js版本: v18.19.0

**重现步骤**:
1. 打开应用
2. 点击登录按钮
3. 输入有效凭据
4. 点击提交

**预期行为**: 用户应该成功登录并跳转到仪表板

**实际行为**: 显示"网络错误",用户停留在登录页面

**错误信息**:

TypeError: Cannot read property 'token' of undefined at LoginComponent.handleLogin (login.component.ts:45)


**截图/录屏**: [附加相关截图或录屏]

**优先级**: High / Medium / Low
**标签**: bug, frontend, authentication
2. Git Branch Creation - 创建Git分支
# 创建并切换到功能分支
git checkout -b fix/login-token-error

# 或者使用更具描述性的分支名
git checkout -b fix/issue-123-login-authentication-error

🔧 Fix the Bug - 修复Bug

Step 1: Reproduce the Issue - 重现问题
# 1. 切换到问题分支
git checkout main
git pull origin main

# 2. 尝试重现Bug
npm start
# 按照问题描述的步骤操作

# 3. 确认问题存在
# 记录重现步骤和错误信息
Step 2: Write Failing Test - 编写失败测试
// 示例:为Bug编写测试用例
describe('LoginComponent', () => {
  it('should handle login with valid credentials', async () => {
    // 这个测试应该失败,因为Bug存在
    const mockUser = { username: 'test', password: 'password' };
    const result = await loginComponent.handleLogin(mockUser);
    
    expect(result.success).toBe(true);
    expect(result.token).toBeDefined();
    expect(result.user).toEqual(expect.objectContaining({
      username: 'test'
    }));
  });

  it('should handle undefined response gracefully', async () => {
    // 测试边界条件
    mockApiService.login.mockResolvedValue(undefined);
    
    const result = await loginComponent.handleLogin(mockUser);
    expect(result.success).toBe(false);
    expect(result.error).toBeDefined();
  });
});
Step 3: Implement the Fix - 实现修复
// 修复前的代码
async handleLogin(credentials: LoginCredentials) {
  try {
    const response = await this.authService.login(credentials);
    // Bug: 没有检查response是否存在
    localStorage.setItem('token', response.token);
    this.router.navigate(['/dashboard']);
  } catch (error) {
    this.showError('登录失败');
  }
}

// 修复后的代码
async handleLogin(credentials: LoginCredentials) {
  try {
    const response = await this.authService.login(credentials);
    
    // 修复: 添加响应验证
    if (!response || !response.token) {
      throw new Error('Invalid response from server');
    }
    
    localStorage.setItem('token', response.token);
    this.router.navigate(['/dashboard']);
    return { success: true, token: response.token, user: response.user };
  } catch (error) {
    console.error('Login error:', error);
    this.showError('登录失败: ' + error.message);
    return { success: false, error: error.message };
  }
}

Read the full file on GitHub · 342 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 1mo ago First seen · 342 lines · 0 tokens per session scan A b56efabe5874

Subscribe to this mod's changes

bug-fix is a cursor rule published in the GitHub repository Mr-chen-05/rules-2.1-optimized (172 stars, last pushed 11mo ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 2,365 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.