---
title: "The Potential of Ruby's ri Command for Coding Agents"
date: 2025-10-29T00:00:00+08:00
publishDate: 2025-10-29T00:00:00+08:00
lastmod: 2025-10-26T20:16:06+08:00
tags: ["Claude Code","Coding Agent","AI","Ruby"]
toc: true
aiTranslated: true
permalink: "https://blog.aotoki.me/en/posts/2025/10/29/ruby-ri-command-potential-for-coding-agent/"
language: "en"
---



Recently, the Hono framework launched the [Hono CLI](https://github.com/honojs/cli) tool, and I quickly created a [Hono Plugin](https://github.com/elct9620/claude-hono-plugin) for Claude Code, adding Agent Skill support for querying documentation using Hono CLI.

At the same time, I realized that the `ri` (Ruby Information) command, which I rarely use, provides similar capabilities to the Hono CLI. Therefore, I created the [Ruby Plugin](https://github.com/elct9620/claude-ruby-plugin) ahead of schedule to provide the `ri` skill.

<!--more-->

## Context {#context}

Context plays a crucial role in the quality of content generation in current LLM (Large Language Model) applications.

This is because when we can provide sufficient information to the LLM, it becomes easier to identify the relevant keywords for subsequent content generation. When a Coding Agent encounters uncertain usage during coding, being able to autonomously search documentation through tools significantly increases the probability of writing correct code.

However, using search tools isn't always precise, as results often mix various personal opinions or incorrect information. In such cases, the "official documentation" provided by packages becomes an extremely high-quality reference standard. It's far better to verify official documentation first and then decide whether to search for more references, rather than relying on search engines directly.

Under this premise, using the `ri` command as the first option is ideal. For example, if we want to confirm the standard usage of `Array#map`, we only need to execute `ri Array#map` to get the correct information without consuming too much context.

## Limitations {#limitation}

However, there are still some limitations when using `ri`. In some simple tests, it's difficult to get Coding Agents (such as Claude Code) to naturally choose the `ri` skill for documentation queries, rather than relying on search or using the `#source_location` method to read the source code directly.

In Claude Code, the Agent Skill description is already quite prescriptive, but the inherent uncertainty of LLMs still makes it hard to ensure `ri` gets priority for documentation lookup. Perhaps better descriptions may emerge in the future, or LLM improvements may help address this.

The current compromise is to provide a `/ruby:info` command that explicitly instructs the use of the `ri` skill to query documentation.

```
/ruby:info how to use expect in rails params
```

This first uses `ri expect` to check for a related `ActionController::Parameters#expect` method, then uses `ri 'ActionController::Parameters#expect'` to read the documentation and explain it to the user.

On the other hand, it's still unclear whether `ri` prioritizes the versions defined in the `Gemfile`, and whether all packages installed through `bundle install` include `ri` documentation by default. These factors limit the ability to leverage this long-existing tool effectively with LLMs.

## Potential {#potential}

Overall, using `ri` is a far more efficient and precise solution than searching for information online, both in terms of speed and Token consumption.

However, it's subject to many limitations. For instance, the Ruby ecosystem has both RDoc and YARD systems. While RDoc can parse YARD content, its presentation can be limited, and we need to confirm whether this affects how `ri` reads documentation.

> Thanks to [Stan Lo](https://x.com/_st0012)'s contributions, RDoc's HTML rendering has become very user-friendly. We should make better use of Ruby's native RDoc to write documentation for packages.

Additionally, during testing, many packages couldn't display documentation properly. Even when certain methods existed, there were sometimes usage issues, or the system lacked documentation saved in the `ri` format. These issues all limit the ability of LLMs to directly use `ri` to verify documentation.

> It would be beneficial if `ri` could support automatic detection of the current directory. This would make it more developer-friendly when using Coding Agents to maintain Gems, allowing the agent to start with documentation rather than searching source code, which is much faster than using `ls`.

