Skip to content

mgiovani/ai-arsenal / skills/create-rule

create-rule

Verified

Create a new memory/instruction rule for whatever AI coding tool a project actually uses, a CLAUDE.md entry or .claude/rules/*.md file for Claude Code, an AGENTS.md entry for Codex/Cursor/Copilot/Gemini-CLI-style tools, or a .cursor/rules/*.mdc file for Cursor. Use when the user runs /create-rule or asks to add a project rule, user/personal rule, coding standard, style guide entry, or workflow instruction to memory, AGENTS.md, or CLAUDE.md. Not for creating skills or slash commands (use create-skill). Not for discovering or installing existing third-party skills (use find-skills).

FileKindSize
SKILL.mdskill md4.5 KB
evals/evals.jsonconfig3.2 KB
evals/trigger-eval.jsonconfig1.8 KB
references/memory-hierarchy.mdmarkdown4.9 KB
references/rule-examples.mdmarkdown4.3 KB

references/rule-examples.md

View on GitHub
# Rule examples

Concrete examples of well-structured memory rules for different tools and scopes.

## Contents

- [Example 1: Claude Code, simple code style rule](#example-1-claude-code-simple-code-style-rule)
- [Example 2: Claude Code, path-specific rule](#example-2-claude-code-path-specific-rule)
- [Example 3: Claude Code, user-level rule](#example-3-claude-code-user-level-rule)
- [Example 4: AGENTS.md, cross-cutting entry](#example-4-agentsmd-cross-cutting-entry)
- [Example 5: Cursor, path-scoped `.mdc` rule](#example-5-cursor-path-scoped-mdc-rule)
- [Writing effective rules checklist](#writing-effective-rules-checklist)

## Example 1: Claude Code, simple code style rule

Command: `/create-rule formatting "Use 2-space indentation and single quotes"`

Creates `.claude/rules/formatting.md`:

```markdown
# Code Formatting

Consistent formatting rules for the codebase.

## Guidelines

- Use 2-space indentation (no tabs)
- Use single quotes for strings (except when string contains single quote)
- Maximum line length: 100 characters
- Add trailing commas in multi-line arrays/objects

## Examples

### Good
```typescript
const config = {
  name: 'my-app',
  version: '1.0.0',
};
```

### Avoid
```typescript
const config = {
    name: "my-app",
    version: "1.0.0"
}
```
```

## Example 2: Claude Code, path-specific rule

Command: `/create-rule api-errors "Standard error handling for API routes"`

Creates `.claude/rules/api-errors.md`:

```markdown
---
paths: src/api/**/*.ts, src/routes/**/*.ts
---

# API Error Handling

Standard error response format for all API endpoints.

## Guidelines

- Use the `ApiError` class for all error responses
- Include error code, message, and optional details
- Log errors with appropriate severity levels
- Never expose internal error details to clients

## Error Response Format

```typescript
interface ErrorResponse {
  error: {
    code: string;
    message: string;
    details?: Record<string, unknown>;
  };
}
```

## Examples

### Good
```typescript
throw new ApiError('VALIDATION_ERROR', 'Invalid email format', { field: 'email' });
```

### Avoid
```typescript
throw new Error(err.stack); // Exposes internal details
```
```

## Example 3: Claude Code, user-level rule

Command: `/create-rule --user preferences "Personal coding preferences"`

Creates `~/.claude/rules/preferences.md`:

```markdown
# Personal Preferences

My personal coding preferences applied to all projects.

## Guidelines

- Prefer functional programming patterns over OOP
- Use descriptive variable names (no single letters except loop indices)
- Add TODO comments with my GitHub username: @myusername
- Prefer async/await over raw promises
```

## Example 4: AGENTS.md, cross-cutting entry

Command: `/create-rule testing "Table-driven tests, no test interdependence"` in a repo
whose only convention file is `AGENTS.md` (no `CLAUDE.md`, no `.claude/rules/`).

Appends a new section to the existing `AGENTS.md` (no separate file, no frontmatter,
the format doesn't support either):

```markdown
## Testing Conventions

- Write table-driven tests (a slice of cases run through one assertion loop), not
  one function per case.
- Tests must not depend on execution order or shared mutable state between tests.
- Name test cases by the behavior under test, not by input value.
```

## Example 5: Cursor, path-scoped `.mdc` rule

Command: `/create-rule react-components "Function components only, typed props"` in a
Cursor repo (has `.cursor/rules/`).

Creates `.cursor/rules/react-components.mdc`:

```markdown
---
description: React component conventions
globs: ["src/components/**/*.tsx"]
alwaysApply: false
---

# React Component Conventions

- Function components only — no class components.
- Type props with an `interface`, not inline object types.
- One component per file, named export matching the filename.
```

## Writing effective rules checklist

1. Be specific: state exact expectations, not vague guidance.
2. Use imperative language: "Use X" not "You should use X".
3. Provide examples: show code snippets of correct (and, where useful, incorrect) patterns.
4. Keep rules focused: one file per topic (AGENTS.md is the exception, since it's one file with a section per topic).
5. Use path restrictions sparingly: only when the rule truly applies to specific file types.
6. Organize with subdirectories: `frontend/react.md`, `backend/api.md` (Claude Code and Cursor only).
reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis.Stars: 471kUpdated Claude CodeCodexVerifiedInstall
diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness.Stars: 322kUpdated Claude CodeCodexVerifiedInstall
dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependenciesStars: 322kUpdated Claude CodeCodexVerifiedInstall
executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is availableStars: 322kUpdated Claude CodeCodexVerifiedInstall