iTranslated by AI

The content below is an AI-generated translation. This is an experimental feature, and may contain errors. View original article
❔

Claude Code Masters Uninstalled Tools!?

に公開

Introduction

My name is Kosuke Naito (@naitokosuke).
I'm currently amazed by Claude Code's vibe coding.
When I throw a research task at Claude Code,

╭─────────────────────────────────────────────────────────────────────────╮
│ Bash command                                                            │
│                                                                         │
│   rg "ナイトウ" --type md                                                │
│   Search for "ナイトウ" in markdown files                                │
│                                                                         │
│ Do you want to proceed?                                                 │
│ ❯ 1. Yes                                                                │
│   2. Yes, and don't ask again for rg commands in                        │
│   /Users/naitoksouke/hoge/fuga                                          │
│   3. No, and tell Claude what to do differently (esc)                   │
╰─────────────────────────────────────────────────────────────────────────╯

it appears.
I didn't even know the rg command.

After searching, I found that Claude Code was trying to use a search tool called ripgrep.
Out of mischief, I chose "1. Yes" to allow it to use an unfamiliar, uninstalled tool.

And what do you know?
Instead of being stuck, Claude Code reported back the research results at lightning speed.

Feeling a bit defeated, I quickly ran:

which rg
which ripgrep

But of course, ripgrep wasn't installed.

So how did Claude Code execute a command that wasn't installed?

Conclusion: Claude Code vendors ripgrep!

In Claude Code's installation directory (~/.claude/local/node_modules/@anthropic-ai/claude-code/vendor/ripgrep), ripgrep is bundled tightly.

Binaries for macOS (arm64/x64), Linux (arm64/x64), and Windows (x64) are provided.

What is ripgrep?

ripgrep is an ultra-fast search tool written in Rust. Designed as a replacement for grep, it has the following features:

  • Blazingly fast
  • Smart
  • Easy to use
  • Unicode support
rg "TODO"
rg "import" --type js  # JavaScript files only
rg "def" --type py     # Python files only

It's faster than grep or ag, and truly shines in large codebases.

Check the Evidence

Take a look at the vendored ripgrep!

ls ~/.claude/local/node_modules/@anthropic-ai/claude-code/vendor/ripgrep

You should see output like this:

arm64-darwin  arm64-linux  x64-darwin  x64-linux  x64-win32

It appears that Claude Code vendors ripgrep.

What is Vendoring?

Vendoring means directly bundling the binaries or source code of external libraries or tools that a project needs, into the project itself.
The benefits of vendoring are:

  • Reduced environment dependency

    • Users can immediately use ripgrep without having to install it themselves
  • Performance guarantee

    • Vendoring allows control over a specific version of the tool
    • No need to worry about old or incompatible versions installed on the system
  • Smoothness

    • Eliminates the hassle of installation, allowing immediate use

Customizing .claude/settings.json

To enjoy vibe coding even more, let's consider customizing .claude/settings.json.

Since ripgrep is a read-only search tool, it should be safe to allow.
We'll add the rg command to the allow list to skip the confirmation dialog.

{
  "permissions": {
    "allow": ["Bash(rg:*)"],
    "deny": []
  }
}

This way, search commands using ripgrep will run smoothly without prompts.

Summary

I didn't know that Claude Code vendors ripgrep.
It's very convenient to be able to use blazing-fast code search immediately without the hassle of installation.

Final Thoughts

Thank you for reading to the end!

GitHubで編集を提案

Discussion