Agent::ContextGuidesGetting Started

Getting Started

This guide explains how to use agent-context, a tool for discovering and installing contextual information from Ruby gems to help AI agents.

Overview

agent-context is a tool that helps you discover and install contextual information from Ruby gems for AI agents. Gems can provide additional documentation, examples, and guidance in a context/ directory.

Installation

Add the gem to your project:

$ bundle add agent-context

Then install agent context files:

$ bundle exec bake agent:context:install

Commands

# See what context is available
bake agent:context:list

# Install all available context
bake agent:context:install

# Install context from a specific gem
bake agent:context:install --gem async

# See what context files a gem provides
bake agent:context:list --gem async

# View a specific context file
bake agent:context:show --gem async --file thread-safety

Understanding context/ vs .context/

Important distinction:

What happens when you install context?

When you run bake agent:context:install, the tool:

  1. Scans all installed gems for context/ directories (in the gem's root).
  2. Creates a .context/ directory in your current project.
  3. Copies context files organized by gem name.

For example:

your-project/
├── .context/           # ← Installed context (with dot)
│   ├── async/          # ← From the 'async' gem's context/ directory
│   │   ├── thread-safety.md
│   │   └── performance.md
│   └── rack/           # ← From the 'rack' gem's context/ directory
│       └── middleware.md
├── lib/
└── Gemfile

Meanwhile, in the gems themselves:

async-gem/
├── context/            # ← Source context (no dot)
│   ├── thread-safety.md
│   └── performance.md
├── lib/
└── async.gemspec

Using Context (For Gem Users)

Why use this?

Key Points for Users

Providing Context (For Gem Authors)

How to provide context in your gem

1. Create a context/ directory

In your gem's root directory, create a context/ folder (no dot):

your-gem/
├── context/            # ← Source context (no dot) - this is what you create
│   ├── getting-started.md
│   ├── configuration.md
│   └── troubleshooting.md
├── lib/
└── your-gem.gemspec

Important: This is different from .context/ (with dot) which is where context gets installed in user projects.

2. Add context files

Create files with helpful information for users of your gem. Common types include:

Focus on the agent experience: These files should help AI agents understand how to use your gem effectively, not document your gem's internal APIs.

3. Document your context

Add a section to your gem's README:

## Context

This gem provides additional context files that can be installed using `bake agent:context:install`.

Available context files:
- `getting-started.md` - Quick start guide.
- `configuration.md` - Configuration options.
- `troubleshooting.md` - Common issues and solutions.

4. File format and content guidelines

Context files can be in any format, but .md is commonly used for documentation. The content should be:

Key Points for Gem Authors

Example Context Files

For examples of well-structured context files, see the existing files in this directory:

Key Differences from API Documentation

Context files are NOT the same as API documentation:

Context files should answer questions like:

Testing Your Context

Before publishing, test your context files:

  1. Have an AI agent try to follow your getting-started guide.
  2. Check that all code examples actually work.
  3. Ensure the files are focused and don't try to cover too much.
  4. Verify that they complement rather than duplicate your main documentation.

Summary