tailwind-spacing-audit
Use when Tailwind spacing looks uneven or too wide: gap, space-x, margin, or padding mixed on navbars, toolbars, and flex rows.
- License 许可
- MIT
- 所属仓库
- tony/skills
- 最近更新
- 2026-11-08
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- tailwind-spacing-audit
- metadata
- { "source": "plugins/tailwind/skills/spacing-audit/SKILL.md", "argument-hint": "<file-or-directory-to-audit>" }
- description
- Use when Tailwind spacing looks uneven or too wide: gap, space-x, margin, or padding mixed on navbars, toolbars, and flex rows.
02 资源文件 4
- 参考文档agents/openai.yaml262 B
- 脚本references/detect.py9.8 KB
- 参考文档references/patterns.md15.1 KB
- 参考文档references/prose-rules.md4.5 KB
03 SKILL.md 正文
Tailwind spacing audit
Detect and fix inconsistent spacing in Tailwind CSS layouts. Most spacing bugs come from fragmented spacing authority: gap, margin, padding, and fixed widths all control the space between the same visual peers. Each pair of adjacent items gets exactly one mechanism.
Use $ARGUMENTS as the target scope. If it is empty and the user pasted
markup, audit the paste. Otherwise ask which component or file to audit;
when asking is not allowed, stop with the halted result below.
Ask only through a question tool, and never when the user said not to ask. Without a question tool, or after that instruction, asking is not allowed: decide per the steps below and end with no question.
Run scripts from the project root so targets stay relative to the
project. Resolve references/detect.py against this skill's directory,
print the absolute path once, and write it literally in each command,
since shell variables do not persist between Bash calls.
Workflow
Step 0: Detect framework and Tailwind version
Find the template files in scope and the class attribute each uses:
*.tsx,*.jsx:className=*.vue:class=,:class=*.svelte,*.astro,*.html,*.erb,*.php,*.twig,*.njk,*.hbs,*.heex,*.mdx,*.liquid:class=
The detect commands in references/patterns.md run
references/detect.py and name an rg fallback. If neither runs,
read the files in scope.
Read the installed Tailwind version with the version command described
in references/patterns.md, run on the project root. If it prints
version: unknown, say so in the result and keep space-x and
space-y advice version-neutral.
Step 1: Structural audit
Scan the component and draw a spacing map in the list form shown under
Output: every spacing mechanism acting on the group the user cares
about. Then read the Detect command limits and Decision tree sections
of references/patterns.md, and only the pattern sections the findings
match.
Call out how many mechanisms act between visual peers, which items sit
in different containers yet read as one group, and any fixed w-* on
an item whose siblings size to content.
Step 2: Classify
Match each finding to a pattern in references/patterns.md. Run that
pattern's detect command for codebase-wide scope. Each match needs a
read in context before it counts. A command that returns nothing for a
file the user named is not a clean bill: read the file.
Step 3: Refactor
Propose the changes as a diff or before/after; edit files only when the user asked to fix or apply them. For a pasted snippet, reply with the code. Preserve existing breakpoints, and change only spacing and sizing classes. Work in this order:
- Merge fragmented containers. Put one visual group in one flex
container with one
gap-*. Remove the outerme-*andms-*that compensated for the split. - Pick one authority per relationship.
gap-*on the parent for uniform spacing; margin on a child only for a deliberate exception; padding only for space inside an item. - Standardize peer envelopes. Peer buttons, links, and toggles
share one height class and one horizontal padding, and no
w-*unless every peer has the same one. - Flatten single-child wrappers. Move the alignment classes onto the child.
- Keep intentional breaks. A divider between nav groups is
deliberate, and so is the margin around it (
mx-*on aw-pxor<hr>element): keep both, never remove or shrink it, and list it as a kept difference with the distance it produces. Ask before normalizing a difference that may be design; when asking is not allowed, keep the break and report it as a kept difference after the findings, never as a finding, with no guessed rationale. Offer a divider, a separate group, or any way to keep a wide gap only when the user said the wide gap is meant to stay. When you keep separate containers, name the evidence that they are separate groups (a divider, different roles, ajustify-between), or merge them. - Report every difference you leave unchanged, such as a peer with different padding: list it as a kept difference or fix it as a finding; never mention it only to guess why it is fine.
Step 4: Validate
After editing files, re-run the detect command for each pattern fixed on the edited files and read the changed lines back; report any hit that remains. Then redraw the spacing map and confirm:
- [ ] Every adjacent pair has exactly one spacing authority
- [ ] Each visual group shares one parent container
- [ ] Peer interactive elements share envelope classes
- [ ] No
w-*on content-sized items, unless all peers match - [ ] Hit targets are consistent across peers
Leave a box [ ] and give the reason for any unmet item; never tick a
box and then argue against it.
Output
Write it per references/prose-rules.md. Present these sections
in order, with these headings:
- Spacing map
- Anti-patterns found: one plain sentence per finding, naming the
mechanism ("margin stacked on gap") and the elements involved, never
a pattern number, with no bold lead-ins. For a file or directory
audit, name each finding's
path:line. Put each kept difference in one plain sentence after the last finding, not among them - Proposed refactor: a focused diff or before/after, with every distance the refactor changes given as old to new ("12px to 8px")
- Validation checklist: Step 4 filled in
Reply in this shape, as plain text outside any code fence, with plain
bullets, no bold (never - **Label:** ...), and no local paths:
## Spacing map
nav (p-4, no gap)
- Docs, gap-2, Pricing
- ms-3 on the second group
- Sign in (px-2 h-8), nothing, Sign up (h-8)
## Anti-patterns found
- The `ms-3` on the second group (`src/Nav.tsx:11`) sets the space between groups, a margin stacked on the parent's gap.
- "Sign in" has `px-2` and "Sign up" has none, so the buttons differ in width.
## Proposed refactor
```tsx
<nav className="flex items-center gap-3 p-4">
...
</nav>
```
## Validation checklist
- [x] Every adjacent pair has one spacing authority.
- [x] Peer buttons share `h-8 px-2`.
Use the full shape when auditing a file or directory. For a pasted snippet with one finding, collapse it to a short explanation and the code, with no bold anywhere and no counted lead-in ("for three reasons:"). State each visible change once. Do not restate that distances stay the same.
State the Tailwind version only when it changes the advice. Distances
assume the default spacing scale (gap-3 is 12px in v3 and in v4, where
--spacing is 0.25rem: v3.4.0 stubs/config.full.js,
v4.0.0 theme.css);
say so once if the project sets a custom theme.spacing or --spacing.
When detect.py reports that it stopped at its hit cap, say which files
it counted and that later files were not scanned.
End a full audit with a next-step panel through the question tool, one option per fix found plus one to extend the audit to another path. Where asking is not allowed, print the options as a plain list, one per line, and stop.
Halted or empty runs give one result sentence, then what the user does:
- No target given: "Nothing audited: no file or directory was given." Pass a file or directory.
- No Tailwind class attributes in scope: "No Tailwind classes found in
<scope>." Check the path, or point at the template files. - Issues found but all kept as deliberate: "No spacing changes made in
<scope>." Stop after one sentence naming the kept break and the one change that would alter it. Do not reprint unchanged code or recap. - No issues found: "No spacing issues found in
<scope>." Name the files you read, since the detect commands can miss dynamic classes.
Portability notes
$ARGUMENTS— the text the user passed when invoking this skill. If your host does not substitute it, read it as the user's request in the current turn, and ask when there is none.- Bundled files — every relative path in this skill points at a file shipped inside this skill directory. Read them from here, not from the host's plugin tree.
04 同仓库更多 Skills
serene-bliss
Use when asked to make a CLI --help, docs page, error message, or tooling UX more serene or calmer for developer experience; returns text, no edits.
review
Weave code review: run independent adversarial reviews in parallel, then synthesize findings
refine
Use when asked to refine a draft, iterate on code until cleaner, or polish a README through repeated critique and improvement.
prompt
Weave prompt: compare independent adversarial implementations, then adopt the single best one
plan
Weave planning: compare independent adversarial plans, then synthesize the best one
fix-review
Fix weave review findings: validate, add test coverage, fix, and commit each as atomic changes