deno-gemini-grounding-mcp-server: Command for Claude Code

.gemini/commands/safe-refactor.md

safe-refactor is a command for Claude Code, Gemini CLI from rinerebox1/deno-gemini-grounding-mcp-server. It costs 0 tokens per session (1,258 once invoked), scanned A, original, MIT.

A command for changing the internal structure of code while keeping its behavior and test coverage. Refactoring means improving code quality or maintainability without intentionally changing what the code does.

In plain words
What is it for?
Use it to improve type safety, error handling, logging, and maintainability while following patterns from the template directory and committing each refactoring step.
Why use it?
It encourages small changes and checks tests before and after each step, making regressions easier to detect. It also provides examples for stronger types, clearer errors, and added logging.

Command for Claude CodeGemini CLI

Written for Gemini CLI and Claude Code: installed under .gemini/, but also a Claude Code command (commands/*.md).

This is rinerebox1/deno-gemini-grounding-mcp-server's own configuration. It tells Claude Code and Gemini CLI how to work on deno-gemini-grounding-mcp-server itself, so it is not a mod to install elsewhere. Copy it as a starting point and replace the rules that are about this project. Everything deno-gemini-grounding-mcp-server configures →

Reuse

Borrowing it

Nothing to install: this file belongs to rinerebox1/deno-gemini-grounding-mcp-server. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.

Copy the file
curl -O https://raw.githubusercontent.com/rinerebox1/deno-gemini-grounding-mcp-server/main/.gemini/commands/safe-refactor.md
Clone the repo
git clone --depth 1 https://github.com/rinerebox1/deno-gemini-grounding-mcp-server

Made for: Claude Code, Gemini CLI.

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 safe-refactor

README.md
[![agentmods](https://agentmods.dev/badge/commands/rinerebox1/deno-gemini-grounding-mcp-server/safe-refactor/github.svg)](https://agentmods.dev/commands/rinerebox1/deno-gemini-grounding-mcp-server/safe-refactor)
Your own site
<a href="https://agentmods.dev/commands/rinerebox1/deno-gemini-grounding-mcp-server/safe-refactor"><img src="https://agentmods.dev/badge/commands/rinerebox1/deno-gemini-grounding-mcp-server/safe-refactor/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 safe-refactor

Your own site · 80×15
<a href="https://agentmods.dev/commands/rinerebox1/deno-gemini-grounding-mcp-server/safe-refactor"><img src="https://agentmods.dev/badge/commands/rinerebox1/deno-gemini-grounding-mcp-server/safe-refactor.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 0 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,258 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.01258
Opus 5 $0.00000 $0.00629
Sonnet 5 $0.00000 $0.00252
Haiku 4.5 $0.00000 $0.00126

Measured 9d ago against content hash 93d2d3297573, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-10, from the pricing page.

Security

Grade A, and why

safe-refactor 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 9d 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.

.gemini/commands/safe-refactor.md · 141 lines

How it starts

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

安全なリファクタリング

テストカバレッジを維持しながら、コードを安全にリファクタリングします。template/ディレクトリの実装パターンを参考にして、コードの品質と保守性を向上させます。

基本原則

  1. テストが通ることを確認 - リファクタリング前後でテストが通ることを保証
  2. 小さなステップで進める - 一度に大きな変更を加えない
  3. パターンの参照 - template/ディレクトリの実装例を参考にする
  4. コミットの頻度 - 各リファクタリングステップでコミット

リファクタリングの種類と手順

1. 型安全性の向上

参考: @template/src/template_package/types.py

# Before: 辞書をそのまま使用
def process_item(item: dict) -> dict:
    return {"id": item["id"], "processed": True}

# After: TypedDictを使用
from typing import TypedDict

class ItemDict(TypedDict):
    id: int
    name: str
    value: int

class ProcessedItemDict(ItemDict):
    processed: bool

def process_item(item: ItemDict) -> ProcessedItemDict:
    return {**item, "processed": True}

2. エラーハンドリングの改善

参考: @template/src/template_package/core/example.py

# Before: 単純なエラー
if not data:
    raise ValueError("Invalid data")

# After: 具体的で実用的なエラー
if not data:
    raise ValueError(
        f"Data cannot be empty when validation is enabled. "
        f"Either provide valid data or set validate=False."
    )

3. ロギングの追加

参考: @template/src/template_package/utils/logging_config.py

from project_name.utils.logging_config import get_logger

logger = get_logger(__name__)

def process_data(data: list) -> list:
    logger.debug(f"Processing {len(data)} items")

    try:
        result = [transform(item) for item in data]
        logger.info(f"Successfully processed {len(result)} items")
        return result
    except Exception as e:
        logger.error(f"Failed to process data: {e}", exc_info=True)
        raise

4. テストの追加・改善

参考: @template/tests/

  • 単体テスト: 正常系・異常系・エッジケース
  • プロパティベーステスト: Hypothesisを使用した自動テスト
  • 統合テスト: コンポーネント間の連携

5. パフォーマンスの最適化

参考: @template/src/template_package/utils/profiling.py

from project_name.utils.profiling import profile, timeit

@timeit
def optimized_function(data: list) -> list:
    # リスト内包表記を使用
    return [item * 2 for item in data if item > 0]

@profile
def heavy_computation():
    # プロファイリング対象の処理
    pass

Read the full file on GitHub · 141 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. 9d ago First seen · 141 lines · 0 tokens per session scan A 93d2d3297573

Subscribe to this mod's changes

safe-refactor is a command published in the GitHub repository rinerebox1/deno-gemini-grounding-mcp-server (0 stars, last pushed 1y ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 1,258 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-09-01.