close-codescan

A command for closing a GitHub Code Scanning alert, which is a notice that automated security checks found a possible problem in code. It shows the alert and records a user-confirmed reason before closing it.

In plain words
What is it for?
Use it to close confirmed false positives, known issues that will not be fixed, or alerts found only in test code.
Why use it?
It helps prevent security alerts from being dismissed accidentally or without an explanation that others can review.

Command for Claude Code

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.

agentmods
npx agentmods add commands/modelengine-group/fit-framework/close-codescan
Clone the repo
git clone --depth 1 https://github.com/ModelEngine-Group/fit-framework

Made for: Claude Code.

Per session 18 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,734 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
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 $0.00018 $0.01734
Opus 5 $0.00009 $0.00867
Sonnet 5 $0.00004 $0.00347
Haiku 4.5 $0.00002 $0.00173

Measured 2d ago against content hash 03159e3dd34c, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

close-codescan 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 2d 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.

.claude/commands/close-codescan.md · 221 lines

How it starts

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

Close Code Scanning Command

功能说明

关闭指定的 Code Scanning(CodeQL)告警。在关闭前会要求用户确认并提供合理的理由,确保不会误关闭真实的安全风险。

执行流程

1. 获取告警信息

gh api repos/{owner}/{repo}/code-scanning/alerts/<alert-number>

验证告警状态:

  • 如果已经是 dismissedfixed 状态,提示用户并退出
  • 如果是 open 状态,继续执行

2. 展示告警详情

向用户展示告警的关键信息:

🔍 Code Scanning 告警 #{alert-number}

严重程度: {security_severity_level} 🔴/🟠/🟡/🟢
规则: {rule.id} - {rule.description}
工具: {tool.name}
位置: {location.path}:{location.start_line}
消息: {message}

3. 询问关闭理由

使用 AskUserQuestion 工具让用户选择关闭理由:

问题: "为什么要关闭这个 Code Scanning 告警?"

选项:

  1. 误报 (False Positive)

    • 描述: CodeQL 规则误判,代码实际上不存在此安全问题
    • 对应 API 参数: dismissed_reason: "false positive"
  2. 不会修复 (Won't Fix)

    • 描述: 已知问题但基于架构或业务原因不予修复
    • 对应 API 参数: dismissed_reason: "won't fix"
  3. 测试代码 (Used in Tests)

    • 描述: 仅在测试代码中出现,不影响生产环境安全
    • 对应 API 参数: dismissed_reason: "used in tests"
  4. 取消

    • 描述: 不关闭告警
    • 操作: 退出命令

4. 要求详细说明

如果用户选择关闭(非"取消"),要求用户提供详细的文字说明:

请提供详细的关闭理由(将记录到 GitHub):

说明要求

  • 最少 20 个字符
  • 清晰说明为什么此告警可以安全关闭
  • 如果是误报,说明为什么代码不存在此安全问题
  • 如果是不修复,说明技术或业务原因

5. 最终确认

显示即将提交的信息,要求最终确认:

⚠️ 即将关闭 Code Scanning 告警 #{alert-number}

规则: {rule.id}
位置: {location.path}:{location.start_line}
关闭理由类别: {选择的理由}
详细说明: {用户输入的说明}

是否确认关闭?(y/N)
  • 如果用户输入 yyes,继续执行
  • 否则,取消操作

6. 执行关闭操作

使用 GitHub API 关闭告警:

gh api --method PATCH \
  repos/{owner}/{repo}/code-scanning/alerts/<alert-number> \
  -f state=dismissed \
  -f dismissed_reason="{API参数}" \
  -f dismissed_comment="{用户的详细说明}"

API 参数映射

  • dismissed_reason 的有效值(根据 GitHub Code Scanning API):
    • false positive: 误报
    • won't fix: 不修复
    • used in tests: 测试代码

7. 记录到任务(如果存在)

检查是否有相关的安全分析任务:

  • 搜索 .ai-workspace/active/.ai-workspace/blocked/.ai-workspace/completed/ 中包含 codescan_alert_number: <alert-number> 的任务
  • 如果找到,在任务文件中添加关闭记录:
closed_at: {当前时间}
closed_reason: {关闭理由类别}
closed_comment: {用户的详细说明}

并将任务移动到 completed/dismissed/ 目录(根据理由)

Read the full file on GitHub · 221 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. 2d ago First seen · 221 lines · 18 tokens per session scan A 03159e3dd34c

Subscribe to this mod's changes

close-codescan is a command published in the GitHub repository ModelEngine-Group/fit-framework (2,117 stars, last pushed 5mo ago), licensed MIT. It adds 18 tokens to every session and 1,734 once invoked, about $0.0001 per session on Opus 5. 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.