Awesome-omni-skill create-rule
Create persistent AI agent rules and instructions. Use when you want to create a rule, add coding standards, set up project conventions, configure file-specific patterns, or create AGENTS.md/GEMINI.md rule files across Cursor, Gemini CLI, or Codex.
git clone https://github.com/diegosouzapw/awesome-omni-skill
T=$(mktemp -d) && git clone --depth=1 https://github.com/diegosouzapw/awesome-omni-skill "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/data-ai/create-rule" ~/.claude/skills/diegosouzapw-awesome-omni-skill-create-rule-84cf31 && rm -rf "$T"
skills/data-ai/create-rule/SKILL.mdCreating AI Agent Rules
Rules provide persistent instructions the agent follows across sessions. Each platform uses a different mechanism—choose based on the current environment.
Platform Overview
| Platform | Format | Project location | Scope control |
|---|---|---|---|
| Cursor | files | | + |
| Gemini CLI | files | | + |
| Codex | files | Anywhere in repo | Directory tree of the file |
Gather Requirements
Before creating a rule, determine:
- Purpose: What should this rule enforce or teach?
- Scope: Should it always apply, or only for specific files/directories?
- File patterns: If file-specific, which glob patterns?
If the user hasn't specified scope, ask:
- "Should this rule always apply, or only when working with specific files?"
If they mentioned specific files without providing patterns, ask:
- "Which file patterns should this rule apply to?" (e.g.,
,**/*.ts
)backend/**/*.py
Use a structured question tool if available, otherwise ask conversationally.
Cursor & Gemini CLI: .mdc
Rule Files
.mdcRules are
.mdc files with YAML frontmatter placed in the platform's rules directory:
.cursor/rules/ # Cursor .gemini/rules/ # Gemini CLI
File Structure
--- description: Brief description of what this rule does globs: **/*.ts alwaysApply: false --- # Rule Title Your rule content here...
Frontmatter Fields
| Field | Type | Description |
|---|---|---|
| string | What the rule does (shown in rule picker) |
| string | File pattern — rule applies when matching files are open |
| boolean | If , applies to every session |
Rule Configurations
Always Apply — universal standards that apply to every conversation:
--- description: Core coding standards for the project alwaysApply: true ---
Apply to Specific Files — conventions scoped to file types:
--- description: TypeScript conventions for this project globs: **/*.ts alwaysApply: false ---
Codex: AGENTS.md
Files
AGENTS.mdCodex reads
AGENTS.md files placed anywhere in the repo. A file's scope covers the entire directory tree rooted at its location. More deeply nested files take precedence over parent ones.
<!-- AGENTS.md at repo root — applies project-wide --> - Always use `async/await` over `.then()` chains. - Run `npm test` after any logic change. - Follow the error handling pattern defined in `src/errors.ts`.
Placement guide:
| File location | Effective scope |
|---|---|
| Entire project |
| Everything under |
| Everything under |
Best Practices
- Under 50 lines: Keep rules concise and focused.
- One concern per rule: Split large rules into separate files.
- Actionable: Write like clear internal docs, not vague guidelines.
- Concrete examples: Show the bad pattern and the correct pattern.
Example (.mdc
)
.mdc--- description: TypeScript error handling standards globs: **/*.ts alwaysApply: false --- # Error Handling \`\`\`typescript // ❌ BAD try { await fetchData(); } catch (e) {} // ✅ GOOD try { await fetchData(); } catch (e) { logger.error('Failed to fetch', { error: e }); throw new DataFetchError('Unable to retrieve data', { cause: e }); } \`\`\`
Checklist
- Correct format for current platform (
vs.mdc
)AGENTS.md - Frontmatter configured correctly (Cursor/Gemini CLI only)
- Content under 500 lines
- Includes at least one concrete example