summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAlmir Sarajčić <[email protected]>2025-07-14 14:06:37 +0200
committerGitHub <[email protected]>2025-07-14 07:06:37 -0500
commit1f4de75348a43f067f1e3dae8adce1444d8589a6 (patch)
treed93aeb9158baf3cc481fe362297efb99d408e2b5
parent457755c690a9d9b6f7c9dfe086f0d47c78a97f23 (diff)
downloadopencode-1f4de75348a43f067f1e3dae8adce1444d8589a6.tar.gz
opencode-1f4de75348a43f067f1e3dae8adce1444d8589a6.zip
Explain usage of external references in AGENTS.md (#965)
-rw-r--r--packages/web/src/content/docs/docs/rules.mdx57
1 files changed, 57 insertions, 0 deletions
diff --git a/packages/web/src/content/docs/docs/rules.mdx b/packages/web/src/content/docs/docs/rules.mdx
index 96b1b3938..aa5590bb5 100644
--- a/packages/web/src/content/docs/docs/rules.mdx
+++ b/packages/web/src/content/docs/docs/rules.mdx
@@ -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.
+:::