Skip to content

Commit f73a88a

Browse files
committed
Add agent context.
1 parent 863d550 commit f73a88a

File tree

12 files changed

+1868
-0
lines changed

12 files changed

+1868
-0
lines changed

.context/agent-context/index.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
description: Install and manage context files from Ruby gems.
3+
version: 0.1.3
4+
metadata:
5+
documentation_uri: https://ioquatix.github.io/agent-context/
6+
funding_uri: https://github.com/sponsors/ioquatix/
7+
source_code_uri: https://github.com/ioquatix/agent-context.git
8+
files:
9+
- path: usage.md
10+
title: Usage Guide
11+
description: "`agent-context` is a tool that helps you discover and install contextual
12+
information from Ruby gems for AI agents. Gems can provide additional documentation,
13+
examples, and guidance in a `context/` ..."

.context/agent-context/usage.md

Lines changed: 173 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,173 @@
1+
# Usage Guide
2+
3+
## What is agent-context?
4+
5+
`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.
6+
7+
## Quick Commands
8+
9+
```bash
10+
# See what context is available
11+
bake agent:context:list
12+
13+
# Install all available context
14+
bake agent:context:install
15+
16+
# Install context from a specific gem
17+
bake agent:context:install --gem async
18+
19+
# See what context files a gem provides
20+
bake agent:context:list --gem async
21+
22+
# View a specific context file
23+
bake agent:context:show --gem async --file thread-safety
24+
```
25+
26+
## Understanding context/ vs .context/
27+
28+
**Important distinction:**
29+
- **`context/`** (no dot) = Directory in gems that contains context files to share.
30+
- **`.context/`** (with dot) = Directory in your project where context gets installed.
31+
32+
### What happens when you install context?
33+
34+
When you run `bake agent:context:install`, the tool:
35+
36+
1. Scans all installed gems for `context/` directories (in the gem's root).
37+
2. Creates a `.context/` directory in your current project.
38+
3. Copies context files organized by gem name.
39+
40+
For example:
41+
```
42+
your-project/
43+
├── .context/ # ← Installed context (with dot)
44+
│ ├── async/ # ← From the 'async' gem's context/ directory
45+
│ │ ├── thread-safety.md
46+
│ │ └── performance.md
47+
│ └── rack/ # ← From the 'rack' gem's context/ directory
48+
│ └── middleware.md
49+
├── lib/
50+
└── Gemfile
51+
```
52+
53+
Meanwhile, in the gems themselves:
54+
```
55+
async-gem/
56+
├── context/ # ← Source context (no dot)
57+
│ ├── thread-safety.md
58+
│ └── performance.md
59+
├── lib/
60+
└── async.gemspec
61+
```
62+
63+
## Using Context (For Gem Users)
64+
65+
### Why use this?
66+
67+
- **Discover hidden documentation** that gems provide.
68+
- **Get practical examples** and guidance.
69+
- **Understand best practices** from gem authors.
70+
- **Access migration guides** and troubleshooting tips.
71+
72+
### Key Points for Users
73+
74+
- Run `bake agent:context:install` to copy context to `.context/` (with dot).
75+
- The `.context/` directory is where installed context lives in your project.
76+
- Don't edit files in `.context/` - they get completely replaced when you reinstall.
77+
78+
## Providing Context (For Gem Authors)
79+
80+
### How to provide context in your gem
81+
82+
#### 1. Create a `context/` directory
83+
84+
In your gem's root directory, create a `context/` folder (no dot):
85+
86+
```
87+
your-gem/
88+
├── context/ # ← Source context (no dot) - this is what you create
89+
│ ├── getting-started.md
90+
│ ├── configuration.md
91+
│ └── troubleshooting.md
92+
├── lib/
93+
└── your-gem.gemspec
94+
```
95+
96+
**Important:** This is different from `.context/` (with dot) which is where context gets installed in user projects.
97+
98+
#### 2. Add context files
99+
100+
Create files with helpful information for users of your gem. Common types include:
101+
102+
- **getting-started.md** - Quick start guide for using your gem.
103+
- **configuration.md** - Configuration options and examples.
104+
- **troubleshooting.md** - Common issues and solutions.
105+
- **migration.md** - Migration guides between versions.
106+
- **performance.md** - Performance tips and best practices.
107+
- **security.md** - Security considerations.
108+
109+
**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.
110+
111+
#### 3. Document your context
112+
113+
Add a section to your gem's README:
114+
115+
```markdown
116+
## Context
117+
118+
This gem provides additional context files that can be installed using `bake agent:context:install`.
119+
120+
Available context files:
121+
- `getting-started.md` - Quick start guide.
122+
- `configuration.md` - Configuration options.
123+
- `troubleshooting.md` - Common issues and solutions.
124+
```
125+
126+
#### 4. File format and content guidelines
127+
128+
Context files can be in any format, but `.md` is commonly used for documentation. The content should be:
129+
130+
- **Practical** - Include real examples and working code.
131+
- **Focused** - One topic per file.
132+
- **Clear** - Easy to understand and follow.
133+
- **Actionable** - Provide specific guidance and next steps.
134+
- **Agent-focused** - Help AI agents understand how to use your gem effectively.
135+
136+
### Key Points for Gem Authors
137+
138+
- Create a `context/` directory (no dot) in your gem's root.
139+
- Put helpful guides for users of your gem there.
140+
- Focus on practical usage, not API documentation.
141+
142+
## Example Context Files
143+
144+
For examples of well-structured context files, see the existing files in this directory:
145+
- `usage.md` - Shows how to use the tool (this file).
146+
- `examples.md` - Demonstrates practical usage scenarios.
147+
148+
## Key Differences from API Documentation
149+
150+
Context files are NOT the same as API documentation:
151+
152+
- **Context files**: Help agents accomplish tasks ("How do I configure authentication?").
153+
- **API documentation**: Document methods and classes ("Method `authenticate` returns Boolean").
154+
155+
Context files should answer questions like:
156+
- "How do I get started?".
157+
- "How do I configure this for production?".
158+
- "What do I do when X goes wrong?".
159+
- "How do I migrate from version Y to Z?".
160+
161+
## Testing Your Context
162+
163+
Before publishing, test your context files:
164+
165+
1. Have an AI agent try to follow your getting-started guide.
166+
2. Check that all code examples actually work.
167+
3. Ensure the files are focused and don't try to cover too much.
168+
4. Verify that they complement rather than duplicate your main documentation.
169+
170+
## Summary
171+
172+
- **`context/`** = source (in gems).
173+
- **`.context/`** = destination (in your project).

0 commit comments

Comments
 (0)