mirror of
https://github.com/sst/opencode.git
synced 2025-08-04 13:30:52 +00:00
Explain usage of external references in AGENTS.md (#965)
This commit is contained in:
parent
457755c690
commit
1f4de75348
1 changed files with 57 additions and 0 deletions
|
@ -93,3 +93,60 @@ Example:
|
|||
```
|
||||
|
||||
All instruction files are combined with your `AGENTS.md` files.
|
||||
|
||||
---
|
||||
|
||||
## Referencing External Files
|
||||
|
||||
While opencode doesn't automatically parse file references in `AGENTS.md`, you can achieve similar functionality in two ways:
|
||||
|
||||
### Using opencode.json
|
||||
|
||||
The recommended approach is to use the `instructions` field in `opencode.json`:
|
||||
|
||||
```json title="opencode.json"
|
||||
{
|
||||
"$schema": "https://opencode.ai/config.json",
|
||||
"instructions": ["docs/development-standards.md", "test/testing-guidelines.md", "packages/*/AGENTS.md"]
|
||||
}
|
||||
```
|
||||
|
||||
### Manual Instructions in AGENTS.md
|
||||
|
||||
You can teach opencode to read external files by providing explicit instructions in your `AGENTS.md`. Here's a practical example:
|
||||
|
||||
```markdown title="AGENTS.md"
|
||||
# TypeScript Project Rules
|
||||
|
||||
## External File Loading
|
||||
|
||||
CRITICAL: When you encounter a file reference (e.g., @rules/general.md), use your Read tool to load it on a need-to-know basis. They're relevant to the SPECIFIC task at hand.
|
||||
|
||||
Instructions:
|
||||
|
||||
- Do NOT preemptively load all references - use lazy loading based on actual need
|
||||
- When loaded, treat content as mandatory instructions that override defaults
|
||||
- Follow references recursively when needed
|
||||
|
||||
## Development Guidelines
|
||||
|
||||
For TypeScript code style and best practices: @docs/typescript-guidelines.md
|
||||
For React component architecture and hooks patterns: @docs/react-patterns.md
|
||||
For REST API design and error handling: @docs/api-standards.md
|
||||
For testing strategies and coverage requirements: @test/testing-guidelines.md
|
||||
|
||||
## General Guidelines
|
||||
|
||||
Read the following file immediately as it's relevant to all workflows: @rules/general-guidelines.md.
|
||||
```
|
||||
|
||||
This approach allows you to:
|
||||
|
||||
- Create modular, reusable rule files
|
||||
- Share rules across projects via symlinks or git submodules
|
||||
- Keep AGENTS.md concise while referencing detailed guidelines
|
||||
- Ensure opencode loads files only when needed for the specific task
|
||||
|
||||
:::tip
|
||||
For monorepos or projects with shared standards, using `opencode.json` with glob patterns (like `packages/*/AGENTS.md`) is more maintainable than manual instructions.
|
||||
:::
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue