Set up btca in your project
Three steps to give your AI agent access to up-to-date documentation and source code.
Install both btca and opencode-ai globally. btca uses OpenCode's SDK for AI completions.
bun add -g btca opencode-aiRequires Bun 1.1.0+
btca uses the OpenCode SDK for AI completions. The easiest way to get started is with OpenCode Zen, which provides access to multiple models with a single API key.
claude-haiku-4-5 opencode RecommendedClaude Haiku 4.5, no reasoning. I HIGHLY recommend this model.
btca config model --provider opencode --model claude-haiku-4-5See all models for other options like Anthropic, OpenAI, and more.
Copy this prompt and paste it into your AI coding agent (like OpenCode, Cursor, or similar). The agent will scan your dependencies, suggest resources, and create a project-specific config.
Set up btca (Better Context) for this project by following these steps:
## Step 1: Scan Dependencies
Check package.json (or equivalent package manager files) and identify libraries/frameworks that would benefit from btca integration. Look for:
- **Frameworks**: Svelte, React, Vue, Next.js, Nuxt, SvelteKit, Remix, Astro
- **Backend**: Effect, Hono, Express, Fastify, tRPC
- **Styling**: Tailwind CSS, UnoCSS
- **Tooling**: TypeScript, Vite, esbuild, Bun
- **Syntax**: Shiki, Prism
- **Other major libraries**: Drizzle, Prisma, Zod, etc.
## Step 2: Present Full Resource List
After scanning, show me the **complete list** of suggested resources in a simple format:
```
Found these dependencies that would benefit from btca:
1. svelte - Svelte framework docs and source
2. tailwind - Tailwind CSS documentation
3. effect - Effect-TS library docs
4. drizzleOrm - Drizzle ORM documentation
... etc
Note: Resource names should be camelCase (e.g., drizzleOrm, not drizzle-orm).
Does this list look good, or would you like to add/remove any?
```
**Wait for my confirmation before proceeding.** I might say:
- "Looks good" - proceed with all
- "Remove X and Y" - exclude those
- "Add Z" - include additional ones
## Step 3: Show Prepared Config
Once I approve the resource list, prepare the full `btca.config.jsonc` with sensible defaults and **show it to me before writing any files**:
```jsonc
{
"$schema": "https://btca.dev/btca.schema.json",
"resources": [
{
"name": "svelte",
"type": "git",
"url": "https://github.com/sveltejs/svelte.dev",
"branch": "main",
"searchPath": "apps/svelte.dev",
"specialNotes": "Svelte docs website. Focus on content directory for markdown docs."
},
{
"name": "tailwind",
"type": "git",
"url": "https://github.com/tailwindlabs/tailwindcss.com",
"branch": "main",
"searchPath": "src/docs"
}
// ... all approved resources
],
"model": "claude-haiku-4-5",
"provider": "opencode",
"providerTimeoutMs": 300000
}
```
Ask: "Here's the config I'll create. Want me to change anything before I write it?"
**Wait for approval** before creating files. I might want to:
- Change a repo URL
- Adjust a searchPath
- Add specialNotes
- Change branch names
## Step 4: Create Files
Only after I approve the config:
1. Create `btca.config.jsonc` in the project root
2. Add `.btca` to `.gitignore` (create the file if it doesn't exist, or append if it does)
## Step 5: Ask About Usage Mode
Ask me which mode I want the agent to use btca in:
```
How would you like your AI agent to use btca?
1. **eager** - Agent uses btca automatically whenever it thinks it needs up-to-date info
2. **ask** - Agent asks you first before using btca to research
3. **lazy** - Agent only uses btca when you explicitly say "use btca" in your prompt
Which mode? (eager/ask/lazy)
```
**Wait for my response** before updating AGENTS.md.
## Step 6: Update AGENTS.md
Check if an `AGENTS.md` file exists in the project root:
- **If it exists**: Look for an existing `## btca` section and update it
- **If it doesn't exist**: Create `AGENTS.md` with the btca section
Add or update this section based on the chosen mode:
**For "eager" mode:**
```markdown
## btca
When you need up-to-date information about technologies used in this project, use btca to query source repositories directly.
**Available resources**: [comma-separated list of all resource names from config]
### Usage
\`\`\`bash
btca ask -r <resource> -q "<question>"
\`\`\`
Use multiple `-r` flags to query multiple resources at once:
\`\`\`bash
btca ask -r svelte -r effect -q "How do I integrate Effect with Svelte?"
\`\`\`
```
**For "ask" mode:**
```markdown
## btca
When you need up-to-date information about technologies used in this project, ask the user if they'd like you to use btca to research.
**Available resources**: [comma-separated list of all resource names from config]
### Usage
\`\`\`bash
btca ask -r <resource> -q "<question>"
\`\`\`
Use multiple `-r` flags to query multiple resources at once:
\`\`\`bash
btca ask -r svelte -r effect -q "How do I integrate Effect with Svelte?"
\`\`\`
```
**For "lazy" mode:**
```markdown
## btca
When the user says "use btca" for codebase/docs questions.
**Available resources**: [comma-separated list of all resource names from config]
### Usage
\`\`\`bash
btca ask -r <resource> -q "<question>"
\`\`\`
Use multiple `-r` flags to query multiple resources at once.
```
## Step 7: Provide Summary
After completing the setup, show me:
1. **Configured resources** (list with name, type, and URL/path)
2. **Config file location** (absolute path)
3. **AGENTS.md status** (created or updated, with which mode)
4. **Example commands** specific to my project's resources
5. **Next steps**:
- "Resources will be cloned to `~/.local/share/btca/resources/` on first use"
- "Use `btca clear` to remove cached git repositories if needed"
- **If using Cursor**: Run this command to install the btca rule file:
```bash
mkdir -p .cursor/rules && curl -fsSL "https://btca.dev/rule" -o .cursor/rules/better_context.mdc && echo "Rule file created."
```- Scan your
package.jsonfor frameworks and libraries - Show you the full list of suggested resources to confirm or modify
- Prepare the complete
btca.config.jsoncand show it for your approval - Create the config file and update
AGENTS.mdwith usage instructions
If you're using Cursor, run this command to install the btca rule file. This teaches your AI agent how to use btca correctly.
mkdir -p .cursor/rules && curl -fsSL "https://btca.dev/rule" -o .cursor/rules/better_context.mdc && echo "Rule file created."Here's what the agent will create. You can also use these as templates for manual setup.
// Example btca project configuration
// Place this file as btca.config.jsonc in your project root
{
"$schema": "https://btca.dev/btca.schema.json",
// Resources available for querying
"resources": [
{
"name": "svelte",
"type": "git",
"url": "https://github.com/sveltejs/svelte.dev",
"branch": "main",
"searchPath": "apps/svelte.dev",
"specialNotes": "Svelte docs website. Focus on content directory for markdown documentation."
},
{
"name": "effect",
"type": "git",
"url": "https://github.com/Effect-TS/effect",
"branch": "main",
"specialNotes": "Main Effect repository with source code and examples."
},
{
"name": "tailwindcss",
"type": "git",
"url": "https://github.com/tailwindlabs/tailwindcss.com",
"branch": "main",
"searchPath": "src/docs",
"specialNotes": "Tailwind CSS docs website. Focus on docs directory."
},
{
"name": "myproject",
"type": "local",
"path": "/absolute/path/to/project",
"specialNotes": "This project's source code for self-reference."
}
],
// AI model configuration
"model": "claude-haiku-4-5",
"provider": "opencode",
"providerTimeoutMs": 300000
}
## btca When you need up-to-date information about technologies used in this project, use btca to query source repositories directly. **Available resources**: svelte, effect, tailwindcss, myproject ### Usage Ask a question about one or more resources: ```bash btca ask --resource <resource> --question "<question>" ``` Examples: ```bash # Single resource btca ask --resource svelte --question "How do stores work in Svelte 5?" # Multiple resources btca ask --resource svelte --resource effect --question "How do I integrate Effect with Svelte?" # Using @mentions in the question btca ask --question "@svelte @tailwind How do I style components?" ``` ### Interactive Mode Start a chat session for deeper exploration: ```bash btca chat --resource svelte --resource effect ``` Or use the TUI: ```bash btca ``` Then use `@mentions` to reference resources (e.g., "@svelte How do I create a store?") ### Configuration This project's btca resources are configured in `btca.config.jsonc` at the project root. To modify: - Edit the config file directly, or - Use `btca config resources add/remove` commands Resources will be cloned to `~/.local/share/btca/resources/` on first use.
Start asking questions
Ask a one-off question about any of your configured resources.
btca ask --resource svelte --question "How do stores work?"Launch the TUI and use @mentions to query resources interactively.
btca