Loading...
Loading...
This skill should be used when the user asks to "create rules", "add custom instructions", "set up AGENTS.md", "configure project rules", "add global rules", or needs guidance on customizing OpenCode behavior with custom instructions.
npx skill4agent add the-perfect-developer/the-perfect-opencode rules-creationAGENTS.md/init/initAGENTS.md# Project rules
touch AGENTS.md
# Global rules
mkdir -p ~/.config/opencode
touch ~/.config/opencode/AGENTS.md# Project Name
Brief description of the project.
## Code Standards
- Use TypeScript with strict mode
- Follow functional programming patterns
## Project Structure
- src/ - Source code
- tests/ - Test filesAGENTS.mdmy-project/
├── AGENTS.md ← Project rules
├── src/
└── package.json~/.config/opencode/AGENTS.mdinstructionsopencode.json{
"$schema": "https://opencode.ai/config.json",
"instructions": [
"CONTRIBUTING.md",
"docs/guidelines.md",
".cursor/rules/*.md"
]
}~/.config/opencode/opencode.json{
"$schema": "https://opencode.ai/config.json",
"instructions": [
"https://raw.githubusercontent.com/my-org/shared-rules/main/style.md"
]
}AGENTS.mdCLAUDE.md~/.config/opencode/AGENTS.md~/.claude/CLAUDE.mdopencode.jsoninstructions# Project Name
Brief 2-3 sentence overview of what the project is.## Project Structure
Directory layout and key files
## Code Standards
Language-specific conventions
## Development Workflow
Build, test, and deployment procedures✓ Good:
- Import shared code using workspace names: `@my-app/core/example`
- All functions go in `packages/functions/`
- Use `bun` not `npm` for package management
✗ Too vague:
- Follow best practices
- Use good code style# SST v3 Monorepo Project
This is an SST v3 monorepo using TypeScript and bun workspaces.
## Project Structure
- `packages/` - Workspace packages (functions, core, web)
- `infra/` - Infrastructure split by service (storage.ts, api.ts)
- `sst.config.ts` - Main SST configuration
## Code Standards
- TypeScript with strict mode enabled
- Shared code in `packages/core/` with proper exports
- Functions in `packages/functions/`
- Infrastructure files in `infra/`
## Monorepo Conventions
- Import shared modules: `@my-app/core/example`
- Use `bun` for all package operations
- Run tests from root: `bun test`/init/initAGENTS.mdAGENTS.md/initinstructions{
"$schema": "https://opencode.ai/config.json",
"instructions": [
"docs/development-standards.md",
"test/testing-guidelines.md",
"packages/*/AGENTS.md"
]
}# Project Rules
## External File Loading
CRITICAL: When you encounter a file reference (e.g., @docs/api-standards.md),
use your Read tool to load it when relevant to the current task.
Instructions:
- Load references on need-to-know basis (lazy loading)
- Treat loaded content as mandatory instructions
- Follow references recursively when needed
## Development Guidelines
For TypeScript style: @docs/typescript-guidelines.md
For React patterns: @docs/react-patterns.md
For API design: @docs/api-standards.md
## General Guidelines
Read immediately: @rules/general-guidelines.mdCLAUDE.mdAGENTS.md~/.claude/CLAUDE.md~/.config/opencode/AGENTS.mdexport OPENCODE_DISABLE_CLAUDE_CODE=1 # Disable all .claude support
export OPENCODE_DISABLE_CLAUDE_CODE_PROMPT=1 # Disable ~/.claude/CLAUDE.md only# Monorepo Project
## Workspace Structure
- `packages/shared` - Shared utilities
- `packages/api` - Backend service
- `packages/web` - Frontend application
## Import Conventions
- Use workspace imports: `@myapp/shared/utils`
- No relative imports across packages
- Run builds from root: `npm run build`## Stack
- **Backend**: Node.js 20, Express, PostgreSQL
- **Frontend**: React 18, TypeScript, Vite
- **Testing**: Vitest, React Testing Library
- **CI/CD**: GitHub Actions
## Key Commands
- `npm run dev` - Start development servers
- `npm run test` - Run all tests
- `npm run lint` - Lint and format## Code Standards
### TypeScript
- Use strict mode
- Prefer interfaces over types for objects
- Explicit return types for exported functions
### React
- Use functional components with hooks
- Co-locate styles with components
- Use named exports, not default
### Testing
- Unit tests in `__tests__/` directories
- Integration tests in `tests/` at root
- Aim for 80% coverage on core logic## API Design
### REST Endpoints
- Use plural nouns: `/users`, `/orders`
- Version in URL: `/api/v1/users`
- Standard methods: GET, POST, PUT, DELETE
### Error Handling
- Return proper HTTP status codes
- JSON error format:
```json
{
"error": "Error message",
"code": "ERROR_CODE"
}
## Troubleshooting
**Rules not applied**:
1. Check file name is `AGENTS.md` (all caps)
2. Verify file is in project root or `~/.config/opencode/`
3. Ensure markdown syntax is valid
4. Restart OpenCode session
**Duplicate rules**:
- If both `AGENTS.md` and `CLAUDE.md` exist, only `AGENTS.md` is used
- Global `~/.config/opencode/AGENTS.md` takes precedence over `~/.claude/CLAUDE.md`
**Instructions not loading**:
1. Validate JSON syntax in `opencode.json`
2. Check file paths are correct
3. Verify glob patterns match intended files
4. Check network connectivity for remote URLs
**Claude Code compatibility issues**:
- Disable with environment variables if conflicts occur
- Migrate to OpenCode conventions for better control
## Additional Resources
### Reference Files
For detailed guidance:
- **`references/file-locations.md`** - Complete file location rules and precedence
- **`references/writing-guide.md`** - In-depth writing best practices
- **`references/advanced-patterns.md`** - Advanced techniques for complex projects
### Example Files
Working examples in `examples/`:
- **`examples/simple-project.md`** - Basic project rules
- **`examples/monorepo.md`** - Monorepo with multiple packages
- **`examples/fullstack.md`** - Full-stack application
- **`examples/global-rules.md`** - Personal global preferences
## Quick Reference
**Create project rules**:
```bash
# Auto-generate
/init
# Or manual
touch AGENTS.mdmkdir -p ~/.config/opencode
touch ~/.config/opencode/AGENTS.md{
"$schema": "https://opencode.ai/config.json",
"instructions": [
"CONTRIBUTING.md",
"docs/*.md",
"https://example.com/rules.md"
]
}AGENTS.mdCLAUDE.md~/.config/opencode/AGENTS.md~/.claude/CLAUDE.mdopencode.jsoninstructionsexport OPENCODE_DISABLE_CLAUDE_CODE=1