---
title: "Rules"
description: "Set custom instructions for OpenCode via AGENTS.md."
section: "configuration"
url: "https://forkline.dev/docs/opencode/rules"
markdown: "https://forkline.dev/docs/opencode/rules.md"
source: "src/content/docs/opencode/rules.md"
---

# Rules

Set custom instructions for OpenCode via AGENTS.md.

> **Official docs**: [opencode.ai/docs/rules](https://opencode.ai/docs/rules)

## Quick Setup

Run `/init` in your repository to auto-generate AGENTS.md:

```
/init
```

This scans your codebase and creates project-specific guidance.

> **Tip**: Commit AGENTS.md to Git so your team shares the same rules.

## What is AGENTS.md?

AGENTS.md contains instructions OpenCode reads before working on your project. It helps:

- Follow your coding standards
- Understand your architecture
- Respect your preferences

## Example

```markdown
# Project Context

TypeScript monorepo using Next.js.

## Code Style
- Use TypeScript strict mode
- Follow existing patterns

## Architecture
- API routes in `app/api/`
- Components in `components/`
```

## File Locations

| Location | Scope |
|----------|-------|
| `.opencode/AGENTS.md` | Project-specific |
| `~/.config/opencode/AGENTS.md` | Global (all projects) |

## Forkline-Specific Tips

1. **Keep it concise** — OpenCode reads AGENTS.md each session
2. **Use setup scripts** — Load shared config via `.forkline/setup.sh`
3. **Point to external docs** — Don't duplicate, reference existing docs

## Related

- [Custom Agents](https://forkline.dev/docs/opencode/agents) — Specialized AI assistants
- [Agent Skills](https://opencode.ai/docs/skills) — Reusable task workflows
- [OpenCode Config](https://opencode.ai/docs/config) — JSON configuration
