---
name: rules
description: Claude Code project-rule loading discipline for LazyClaude session context, prompt hooks, post-edit checks, and repo-local guidance.
---

# Rules

Use this skill when rule loading, prompt context, or project guidance is part of
the task. It adapts LazyClaude rules component to Claude Code's plugin and hook
surface.

## Rule Sources

LazyClaude should respect repository guidance from:

- `CLAUDE.md`
- `AGENTS.md`
- `.claude/rules/**/*.md`
- `.github/instructions/**/*.md`
- project-specific plans and handoff files when the user names them

Do not assume every repository has all files. Missing guidance is normal; stale
guidance should be labeled and not silently treated as active truth.

## Injection Principles

- Session-start context should be compact and stable.
- Prompt-submit context should activate only on clear triggers.
- Post-tool-use context should be limited to the edited surface.
- Hooks must never echo untrusted prompt text as executable shell.
- Hooks must return valid JSON or fail with a controlled error.

## Trigger Discipline

For LazyClaude ULW triggers, recognize `ulw`, `ultrawork`, `$ulw-plan`,
`$ulw-loop`, and `$start-work`. The hook may instruct Claude to load or follow
the matching skill semantics. It should not pretend to run slash commands that
belong to the UI.

## Priority

Use this precedence when rules conflict:

1. Explicit user instruction in the current turn.
2. System/developer/tool safety instructions.
3. Repository guidance in the active workspace.
4. LazyClaude skill defaults.
5. General preferences.

When a lower-priority rule conflicts with a higher-priority one, follow the
higher-priority rule and mention the conflict only if it affects outcome.

## Post-Edit Feedback

Post-edit rule checks should be actionable and small:

- identify the touched file or tool
- queue diagnostics or tests where relevant
- avoid long policy dumps after every edit
- never claim diagnostics ran when they were merely suggested

## Evidence

Rules work is verified by hook tests and real hook invocation. For this repo,
use `test/hooks.test.mjs` and a CLI invocation of
`plugins/lazyclaude/bin/lazyclaude-hook.js` with concrete JSON input.
