Setup

From melodic-software/claude-code-plugins · View interactive version

Setup is an AI agent skill from the GitHub repository melodic-software/claude-code-plugins. Checks or scaffolds this repository's code-tidying configuration: tracked project tidy lanes, the optional HARD-exclusion overrides file, the comment-lint git pre-commit entry, and the CI step that re-runs the lint. Use when 'set up code-tidying' is asked, the tidy skill reports no project lanes, or

How to use this skill

Skill file

Purpose

Verify and scaffold the consuming repo's tracked lane definitions at .claude/tidy-lanes/<lane>.md,

so /code-tidying:tidy resolves project-specific scope globs and watch-for patterns instead of the

generic bundled lanes. A project lane at ${CLAUDE_PROJECT_DIR}/.claude/tidy-lanes/<lane>.md layers

over the bundled lane of the same name: one declaring ## Merge semantics merges per section with

the bundled lane, one without it resolves project-only (the tidy skill's Lane resolution).

Project lanes are optional: with none, tidy uses the bundled lanes, so their absence is an INFO,

never a FAIL. The skill follows the uniform setup contract (docs/plugin-philosophy.md "Setup is

explicit and repeatable" in the marketplace repository): no argument or check inspects

read-only; check inspect runs only the check inspect section; apply runs the check, scaffolds or retunes lanes, then re-runs check; apply <lane>

targets one lane. Re-running reads the existing lane files and proposes changes against them rather

than overwriting a consumer lane blind.

Lanes vs. templates

cover surfaces that look the same in most repos and resolve with no config. A project override

is worth writing only when this repo's tooling or doc directories differ from their defaults.

<placeholder> scaffolds for lanes that are project-specific by design: code the repo has but no

generic lane can name. Turning the fitting templates into real lane files is this skill's main

job.

Never tell the user to "copy the bundled lanes": scaffold from templates, and override a bundled

lane only when its defaults miss this repo's layout.

The plugin's second tracked file is ${CLAUDE_PROJECT_DIR}/.claude/code-tidying/exclusion-overrides.md,

optional and absent by default: root-relative globs that lift GLOBAL HARD path exclusions for

every run in this repository, the subtracting mirror of the consumer-declared protections that add

to them. check validates it; apply writes it only when the user asks. Contract, shape,

precedence, and what no channel lifts: the tidy skill's

exclusions reference section 4.

`check` (read-only)

Report a PASS/FAIL/INFO table with one remediation line per FAIL. Modify nothing, and do not run a

tidy sweep (that is /code-tidying:tidy).

  1. Project lanes present. List .claude/tidy-lanes/*.md. None → INFO: tidy resolves the

bundled lanes; apply scaffolds project lanes when this repo's layout diverges from them.

  1. Lane structure. Each lane carries ## Scope, ## Watch-for patterns,

## Lane-specific extra exclusions, ## Verification commands, ## Conventional Commits type,

and ## Preferred research sources; a missing section is FAIL. Exception: a lane that declares

## Merge semantics and shares its name with one of ${CLAUDE_PLUGIN_ROOT}/skills/tidy/lanes/*.md

inherits every section it omits, so report which sections it inherits instead. The exemption

belongs to the declaration, not the heading: confirm the section either adopts the bundled lane's

declaration by reference (the shape apply writes, `Merge semantics: per the bundled lane's

declaration`) or states a disposition for every required section the lane omits. An empty,

unrelated, or silent-on-an-omitted-section declaration is FAIL (malformed merge declaration;

remediation: adopt the bundled declaration by reference or state the missing dispositions).

  1. No unreplaced placeholders. A leftover template <placeholder> is a broken scope glob or

watch-for pattern: FAIL, naming the file and the token.

  1. Tracked, not ignored. Per lane file, run both halves of the tracked-file pair:

git check-ignore -v <file> (non-empty means a .gitignore pattern excludes the lane: FAIL with

the pattern, since a directory can be tracked while a pattern excludes one .md inside it) and

git ls-files --error-unmatch <file> (non-zero means un-ignored but untracked: report "commit it

to share with the team", downgraded to INFO only when the user confirms a deliberately private,

uncommitted lane).

  1. Bundled lanes and templates. INFO: list them as the scaffold sources apply can use.
  2. HARD-exclusion overrides. Absent is the normal state: INFO naming the file and what it does.

Present: check it against section 4 of the exclusions reference: an ## Overrides heading with

one fenced block, one root-relative glob per line. FAIL an absolute path or an entry containing

.., naming the line. FAIL a glob matching the overrides file itself or the .claude/tidy-lanes/

definitions beside it: the file cannot lift its own protection. FAIL a glob that also matches a

path this repo's CLAUDE.md / .claude/rules declare protected, naming both declarations: the

protection wins and the override is dead text. Run both halves of the tracked-file pair on it as

for a lane file (git check-ignore -v reports no match, git ls-files --error-unmatch exits 0),

since it is a team statement that counts only when committed. Report the globs it lifts.

  1. hard_exclusions posture. Report the stored userConfig value. enforce (default) is PASS.

advisory is INFO, not a FAIL, a deliberate operator posture, and the report line states what it

does: every GLOBAL HARD path entry is reported instead of blocking, in every run this operator

makes. If the value changed this session, say the

running session's behavior is not yet established: the stored value is current, the session lags.

  1. Comment-lint git entry. Outside a git repository, INFO and skip this step. Probe node

(command -v node && node --version): absent is a FAIL, since the installer and the

session-start drift probe run on it; an installed entry still runs at commit. Then run

node "${CLAUDE_PLUGIN_ROOT}/lib/git-hooks/install.mjs" verify from the repository. Each line

is <state>\t<entry>[\t<detail>]: ok is PASS, declined is INFO, and missing, stale,

modified or superseded is a FAIL whose remediation is apply install-git-hooks.

  1. Comment-lint settings and tools. Run "${CLAUDE_PLUGIN_ROOT}/scripts/comment-settings.sh"

and report comment_lint (off when unset), comment_posture, and the file each came from;

comment-settings.sh --list comment_lint_allow lists the allow patterns and

--list comment_lint_exclude the excluded path globs. A comment_lint

invalid line is a FAIL naming the file. When the level is report or block, probe

python3 -c 'import pygments' with the python3 on PATH: a failure is a FAIL, since the entry

then reports pygments missing at every commit. Report python3 and pygments as the tools to

provision before an unattended session.

  1. Comment-lint CI re-run. Run

python3 "${CLAUDE_PLUGIN_ROOT}/scripts/comment-lint-ci-scan.py" --repo <repository root> and

report its systems and callers. A script caller with no decision against it is PASS,

named by file and line. An unreached-caller is a FAIL naming the target and the CI files

checked: no CI job runs it or any other caller, remediation apply install-ci. A

local-caller is INFO: a local target CI does not run, beside a caller CI does reach. A drift decision is a FAIL naming the call, its args and the

interface, remediation apply install-ci. A recipe-caller is INFO: the job runs the lint

by hand, and apply install-ci moves it to the shipped script. An unparsed caller is INFO:

read the line. With no caller (no-caller or no-ci-system) say so as INFO, remediation

apply install-ci: the missing-tool pass and checks.skipmissing rely on CI re-running the

lint on the change.

`apply` (idempotent)

Run check, then resolve each lane by the convention ladder: config present → use it; absent →

infer from the repo and persist; cannot infer → ask and offer to persist; else a safe default (skip

that lane, no empty file). Proceed non-interactively wherever the invocation and the repo make the

answer unambiguous; ask only where a lane's scope genuinely needs the user's call.

  1. Read existing lanes first. If any exist, summarize each (name, scope globs, watch-for count)

and propose changes against that baseline. **Never overwrite an existing consumer lane without

explicit confirmation in this conversation.**

  1. Explore the repo to draft candidate lanes before asking anything. Map the four template

patterns against what actually exists, reading real directory names and extensions and assuming

no stack, and skip any pattern the repo has no surface for:

web/API/CLI app roots and their sibling test projects.

shared, domain, or core library roots that downstream code depends on.

composition roots, DI wiring, logging, registration, service defaults.

non-primary-language services, MCP servers, sidecars.

repo's tooling or doc directories diverge from the bundled scope.

Under apply <lane>, scope this to that lane.

  1. Interview, one lane at a time, recommendation first and the highest-blast-radius lane

first. Present each candidate with its inferred globs and source template; let the user accept,

edit the globs, or drop it. Offer a custom lane last ("any other glob-scoped slice this repo

should tidy on its own rotation?").

  1. Fill each accepted lane from real repo values. Read its source in full, then replace every

<placeholder> (templates) or bundled default (overrides):

(${CLAUDE_PLUGIN_ROOT}/skills/tidy/templates/<pattern>-lane.template.md).

and write only the sections this repo diverges on (usually ## Scope, sometimes extra

exclusions) plus a ## Merge semantics section adopting the bundled lane's declaration.

six sections. Never emit a lane missing a section.

Fill scope globs from real paths, watch-for patterns tuned to the stack, lane-specific exclusions

for this repo's unverifiable surfaces, verification commands from the project's own CLAUDE.md,

rules, or CI config (never invented), the Conventional Commits type, and preferred research

sources. Leave no <placeholder> behind.

  1. Write the lane files the user confirmed at .claude/tidy-lanes/<lane>.md; no empty

scaffolds.

  1. Verify after remediation. Re-run the check probes on each written file: required sections,

no leftover placeholder, and both halves of the tracked-file pair. A git check-ignore -v match

means a .gitignore pattern excludes the lane: surface it and offer to fix .gitignore before

reporting success. A non-zero git ls-files --error-unmatch is the expected state right after a

fresh write: report "written but untracked: commit it to share with the team", never success,

since these lanes are team-shared and reach the team only once committed. tidy resolves a lane

only from .claude/tidy-lanes/<lane>.md (then the bundled lane of that name), with no

user-global layer or *.local.* personal override (a declared deviation from the config-cascade contract). Never

point a developer at a *.local.* variant tidy would not load; a private lane uses a lane name

the team does not track, kept uncommitted (never add it to the index).

  1. Offer the overrides file only when the repo asked for one: the conversation named a path the

plugin keeps dropping, or check reported a malformed existing file. Absent is correct for almost

every repository, and an empty overrides file is the empty scaffold step 5 forbids. Write

${CLAUDE_PROJECT_DIR}/.claude/code-tidying/exclusion-overrides.md in the section 4 shape (an

## Overrides heading, one fenced block, one root-relative glob per line, # comments) with only

globs the user named, preserving any prose already in the file. Re-run the step 6 probes on it,

report it as written but untracked until committed, and state plainly what it loosens.

Re-running apply after everything passes changes nothing and reports "already configured".

`check inspect` (read-only)

Lists what runs at each git hook stage in this repository, under whichever hook manager it uses,

and times this plugin's own entries. Run

node "${CLAUDE_PLUGIN_ROOT}/lib/git-hooks/install.mjs" inspect from the repository (add

--runs <n> to time each entry more often) and render its JSON as one table per stage: each item's

kind, name and source, then its measured median and range with the input it ran on and its exit

codes, or not measured with the notMeasured reason. A stage whose installed is false has no

hook file git runs: say the manager's install step has not run in this clone. The script runs only

this plugin's installed entries that change no files and still match what the plugin ships; it never runs a repository's own hook,

another plugin's entry, a lefthook job or a Husky.Net task. To place a new check, compare the

numbers with the duration budgets in the check-placement contract

(docs/contracts/check-placement/README.md#duration-budgets in the marketplace repository).

Modify nothing. Outside a git repository, report INFO and stop.

`apply install-git-hooks [scope=local|shared]`

Registers the plugin's git-hook entry (git-hooks/entries.json, comment-lint at pre-commit)

with the repository's hook manager. The installer only detects, renders and writes files the

plugin owns; every step that needs judgment comes back as a decisions[] item, which you reason

about and apply with your own edit tools. The entry exits 0 while comment_lint is off or unset,

so installing it changes no commit until the team file sets a level.

  1. Scope. Use the argument when given. Otherwise, when the user is present, ask: local (this

clone only, nothing committed) or shared (committed for the team, so every

teammate and agent gets it). When nobody can answer, use local.

  1. Plan. For local, run `node "${CLAUDE_PLUGIN_ROOT}/lib/git-hooks/install.mjs" plan

--scope local. For shared, run plan --scope remote` first: with lefthook, or no hook manager

yet, the committed lefthook.yml gets one remotes: entry naming the marketplace's root

lefthook-remote.yml, which fetches every plugin's hooks from its main branch, so nothing is

copied and no refresh is ever committed. When it returns remote-needs-lefthook (husky or plain

hooks) or remote-source-dir, run plan --scope shared instead, which commits copies under

.githooks/code-tidying/. Read the JSON: manager, actions[], decisions[].

  1. Manager conflict. A manager-conflict decision lists the evidence. Show it and ask which

manager should carry the entry; rerun plan with --manager lefthook|husky|plain. Without an

answer, stop and report.

  1. Actions. A remote plan has none. When actions[] holds copy items, run

node "${CLAUDE_PLUGIN_ROOT}/lib/git-hooks/install.mjs" copy --scope <scope> (with the same

--manager when you passed one). It prints installed, refreshed, unchanged, refused or

blocked per entry; refused is a locally edited copy (the modified decision) and blocked

is another tool owning the local hooks directory (the hooks-path-owned decision).

  1. Decisions. Read reference/git-hook-decisions.md for what

each kind asks of you, apply each one, then rerun plan until only the decisions you chose to

leave remain. With a no-ci-rerun decision, also offer apply install-ci.

  1. Verify. Run verify and report its lines as check step 8 does.

A remote entry stays in the committed lefthook.yml, so stop it in one clone by skipping its job,

code-tidying-remote-<entry>, in the clone's untracked lefthook-local.yml; a failing remote job prints

that skip, and the [adoption

path](https://github.com/melodic-software/claude-code-plugins/blob/main/docs/contracts/check-placement/adopting-git-hooks.md#when-a-remote-job-breaks)

says when to use it and how to drop it.

When the user does not want the entry in this clone, run

node "${CLAUDE_PLUGIN_ROOT}/lib/git-hooks/install.mjs" decline --entry comment-lint; the

session-start drift line then stays silent until verify runs by hand, and --undo reverses it.

Add --global to decline it in every clone. The [adoption

path](https://github.com/melodic-software/claude-code-plugins/blob/main/docs/contracts/check-placement/adopting-git-hooks.md)

explains each install scope to the user.

`apply install-ci`

Adds a CI step that re-runs the comment lint over each change, judged against the base branch's

settings, so a commit that skipped the git hook is still checked. The plugin ships the step's

script, git-hooks/comment-lint-ci.sh <head> <base> (its --help is the interface); the wiring is

the repository's own, written in its CI system's format after discovery. No CI system is a default

and no vendor template ships: reference/ci-systems.md holds what the step

does in any system, where the script comes from, and how to read the system's own docs.

The scan is python3 "${CLAUDE_PLUGIN_ROOT}/scripts/comment-lint-ci-scan.py" --repo <repository root>

(read-only JSON). Read actions/install-ci.md and follow its six steps:

discover, stop when the step is there, ask only what discovery leaves open, propose, write only on

the user's yes, verify.

Personal configuration (`userConfig`)

Not apply surface: Claude Code owns the storage, and this contract forbids setup to write

pluginConfigs, so check reports the observed value and routes the change. Reconfigure through

Claude Code's native flow, interactively with /plugin configure code-tidying@<marketplace> or by

a headless route, as the marketplace's plugin-reconfiguration convention gives them in

§ The routes

(it owns the verified-version record). Apply the scope and failure-signal caveats in its

§ Caveats every setup skill's short form carries.

Read both sections and print what they give, the fallback route, its behavior on an

already-installed plugin and the scope to pass included, rather than only naming them, and

leave out the verified-version record.

Never uninstall to reconfigure; that section links what an uninstall deletes. This skill never

writes user settings or pluginConfigs. Afterwards rerun check in a fresh session, since a

same-session check can still show the old value, and report the observed effective value, never

an unobserved change. hard_exclusions takes enforce (default, every GLOBAL HARD path entry

blocks) or advisory (every one is reported and none blocks); any other value is read as

enforce. The full option table is in the plugin README.

when a saved value applies, fetch

plugin CLI reference § plugin configure

live.

Output

Tracked .claude/tidy-lanes/<lane>.md file(s) in the consuming repo, plus a one-paragraph summary

of which lanes were written, the source of each (template or bundled lane), and how to re-run this

setup to add or retune lanes. When an overrides file was written or already exists, the summary

names it and the globs it lifts. apply install-git-hooks writes only the entry's copies and

its hook-manager wiring, and reports verify's lines. apply install-ci writes one CI step, in a

file the user confirmed, and reports the scan's caller for it.

Boundaries

state: lane configuration lives in the consumer's tracked .claude/tidy-lanes/, never in the

plugin directory or a plugin data directory.

they cannot drift from the source.

Gotchas

§ Caveats every setup skill's short form carries

links what an uninstall deletes, and

§ The routes

covers what an install rerun does to stored options.

inheriting bundled improvements. Write only the sections that diverge.

visible to Git regardless of .gitignore.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.