/mz-rules:init-rules [project|global] [--target=rules|claudemd] [--force] [--uninstall]from Mozg Coding Rules
Installs coding rules per project or globally, fitted to the stack it reads itself. Use when the user wants the same habits in a project or every session ("init rules", "install rules", "onboard project"). Not for Obsidian vaults (use obsidian-init).
Ships in Mozg Coding Rules. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Install curated development rules based on detected project context. Two delivery modes:
--target=rules (default) — write rule files into .claude/rules/ (project) or <CONFIG_DIR>/rules/ (global). Files with paths: frontmatter stay path-scoped.--target=claudemd — inject rule content directly into ./CLAUDE.md (project) or <CONFIG_DIR>/CLAUDE.md (global), wrapped in sentinel blocks for idempotent re-runs and clean uninstall.Personal preference groups install only when the user picks them, and so does the Delegation group, which routes web research, wide searches and docs writing to specialised agents. Every install also proposes a few settings entries that Claude Code enforces on its own (ask before git push, deny .env reads, a pre-commit Stop hook, attribution off). Re-runs also clean up stale content: rules this skill has retired, installs from older versions, and hand-written CLAUDE.md copies of retired or rewritten sections. One approval gate covers all of it together with the settings.
Installing, refreshing or uninstalling curated development rules for one project or globally, as rule files or CLAUDE.md blocks.
obsidian-init (mz-knowledge).--target=rules; claudemd mode cannot path-scope.project (default) → scope to working directoryglobal → scope to <CONFIG_DIR> (~/.claude/ unless CLAUDE_CONFIG_DIR is set)--target=rules (default) → write as individual rule files--target=claudemd → inject into CLAUDE.md with sentinel blocks--force → overwrite existing rule files / replace existing sentinel blocks, including unmarked legacy files from older installs--uninstall → remove rules previously installed by this skill (mode-aware) and the settings entries it adds, exact matches onlyParse from $ARGUMENTS. Unknown or conflicting tokens → AskUserQuestion; never guess.
${CLAUDE_SKILL_DIR}${CLAUDE_PLUGIN_ROOT}echo "${MZ_MEMORY_ROOT:-$(git rev-parse --show-toplevel 2>/dev/null || pwd)}"; expand <PROJECT_ROOT> to it in every command and agent prompt.<PROJECT_ROOT>/.mz/task/printf '%s\n' "${CLAUDE_CONFIG_DIR:-$HOME/.claude}". Claude Code reads user rules, the user CLAUDE.md and user settings from there, so global scope writes all three under it.Phase files write <SKILL_DIR>, <PLUGIN_ROOT>, <PROJECT_ROOT> and <CONFIG_DIR> because they get no variable substitution when read. Replace each with the absolute path above before reading a file or running a Bash command.
| Phase | Goal | Details |
|---|---|---|
| 0 | Setup | Inline below |
| 1 | Select, approve, and apply rule changes | phases/run.md |
| 1 | Plan and apply settings entries | phases/enforce.md, from run.md Steps 5 and 7d |
PROJECT_ROOT with the command in Constants, before any cd or worktree switch, and use it for every .mz/ path below. Resolve CONFIG_DIR the same way.$ARGUMENTS: scope (project/global), target (rules/claudemd), --force, --uninstall. Unknown token → AskUserQuestion.task_name = <YYYY_MM_DD>_init_rules_<scope>_<target> where <YYYY_MM_DD> is today's date (underscores); on same-day collision append _v2, _v3.<TASK_DIR><task_name>/.state.md with schema_version: 2, Status: running, Phase: 0, Started: <ISO>, phase_complete: false, what_remains: [], Scope: <project|global>, Target: <rules|claudemd>, Force: <bool>, Uninstall: <bool>, DetectedContexts: [], AgentsMd: n/a, PersonalGroups: [], Delegation: skip, Installed: [], Replaced: [], Upgraded: [], Skipped: [], Removed: [], Retired: [], HandRemoved: [], SettingsAdded: [], SettingsRemoved: []. schema_version: 2 is the first line of the file.Every run, in both modes and for uninstall, passes the single approval gate in Phase 1 Step 6 before its first write. That one confirmation covers every write in the run.
Read phases/run.md and proceed to Phase 1.
${CLAUDE_SKILL_DIR}/references/retired.md: the retired rule ids and the renamed or rewritten CLAUDE.md sections that the stale scan looks for. Read it in full in Phase 1 Step 5 on install, and again in Step 7c on uninstall before deleting rule files.<SKILL_DIR> is still a literal ${...} token or the bundled rules/ directory is not readable, AskUserQuestion with the failing path.unknown for the version tag and note it in the report.jq not installed → skip the settings step, say so in the plan, and print the settings fragment in the report for manual use.After each phase, update <TASK_DIR><task_name>/state.md with:
Status: pending | running | blocked | complete | aborted_by_user | failedPhase: current phase numberDetectedContexts: list of detected language/tooling tagsAgentsMd: the AGENTS.md guard answer from Phase 1 Step 1 (import, rules, claudemd-only, or n/a)PersonalGroups: personal groups chosen in Phase 1 Step 4Delegation: the Delegation group answer from Phase 1 Step 4 (install, installed or skip)Installed: / Replaced: / Upgraded: / Skipped: / Removed: / Retired: filenames or rule ids touched in this runHandRemoved: headings of hand-written CLAUDE.md sections removed by the stale scanSettingsAdded: / SettingsRemoved: settings entries written or removedExcluded: paths appended to .git/info/exclude (.mz/, .claude/settings.local.json)Never rely on conversation memory for cross-phase state — context compaction destroys specific paths and decisions.
State persists to .mz/task/<task_name>/state.md under the project root, ${MZ_MEMORY_ROOT:-$(git rev-parse --show-toplevel 2>/dev/null || pwd)}, resolved once at the start of the run. Schema is v2: line 1 is schema_version: 2; line 2 is Status: with one of pending, running, blocked, complete, aborted_by_user or failed, lowercase and unquoted; then Phase, Started, phase_complete (boolean) and what_remains (YAML list of strings), with skill-specific keys below them. Milestones go in Phase; the reason for blocked or failed goes in what_remains. Set phase_complete: false on phase entry and true once the phase's artifacts are written and its gates pass. Refresh what_remains on every phase transition; it is [] when Status is complete. Write the file after every phase and before every gate, and re-read it after compaction. Record decisions worth recalling under a heading that reads exactly ## Decisions, placed before ## Notes; mz-memory harvests them only once Status is complete. Under a heading that reads exactly ## Lessons, add one line whenever a review finding is accepted and fixed, a step fails, gate feedback corrects a mistake, or an approved approach is reversed, in the form - (review|failure|correction|change) WHEN <situation> → <what to do> — WHY <cause>, concrete and under about 40 words; mz-memory harvests lessons whatever the Status. Treat a legacy completed as complete. On reading a schema_version: 1 or unversioned file, put schema_version: 2 on line 1 and Status on line 2, add the missing keys, and log the upgrade. Leave a file with a higher schema_version untouched: ask whether to Restart (archive it), start New (_v2) or Abort, and stop if nobody can answer.
phases/enforce.md (opens in a new tab)phases/run.md (opens in a new tab)references/retired.md (opens in a new tab)rules/agent-workflow.md (opens in a new tab)rules/code-quality.md (opens in a new tab)rules/coding-standards.md (opens in a new tab)rules/context-safety.md (opens in a new tab)rules/delegation-naturalize.md (opens in a new tab)rules/delegation.md (opens in a new tab)rules/edit-safety.md (opens in a new tab)rules/git-conventions.md (opens in a new tab)rules/housekeeping.md (opens in a new tab)rules/personal-code-style.md (opens in a new tab)rules/personal-cpp.md (opens in a new tab)rules/personal-git.md (opens in a new tab)rules/personal-review.md (opens in a new tab)rules/pre-commit-conventions.md (opens in a new tab)rules/python-conventions.md (opens in a new tab)rules/safety.md (opens in a new tab)rules/self-evaluation.md (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
npx claudepluginhub doctormozg/claude-pipelines --plugin mz-rules