Skills DirectorySkills Directory
SkillsLearnSecurityCategoriesDocsBlogPro
Sign InSubmit Skill
Skills Directory

Security-tested agent skills for Claude, coding agents, and AI workflows.

Directory

  • Browse Skills
  • All Skills A–Z
  • Claude Skills
  • Claude Code Skills
  • Agent Skills
  • Categories
  • Authors
  • Submit a Skill

Learn

  • Learn Hub
  • Install Claude Skills
  • Write SKILL.md
  • Skills vs MCP
  • Directories Compared

Security

  • Security
  • Methodology
  • Secure Claude Skills
  • Security Badges
  • Chrome Extension
  • Skill Manager

Company

  • About
  • Community
  • Blog
  • API Docs
  • Advertise

2026 Skills Directory. All rights reserved.

ProTermsPrivacyRefunds
Back to skills

Tailwind Spacing Audit

ASecurity

Use when Tailwind UI spacing, alignment, gaps, margins, padding, or toolbar and navbar rhythm looks inconsistent.

3 stars
0 votes
0 copies
3 views
Added 9/19/2026
ai-agentsgophpreactvuerailsrefactoringapi

Works with

cliapi

Security Analysis

A100/100

Pro scans all 3 files and shows the line behind each finding

Scanned 9/19/2026

$npx -y skills add tony/skills --skill tailwind-spacing-audit --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Tailwind Spacing Audit?

Add the live security badge to your README — it updates automatically with every re-scan.

Security grade badge for Tailwind Spacing Audit
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/tony-tailwind-spacing-audit/badge)](https://www.skillsdirectory.com/skills/tony-tailwind-spacing-audit)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
Files
SKILL.md
---
name: tailwind-spacing-audit
description: >-
  Use when Tailwind UI spacing, alignment, gaps, margins, padding, or
  toolbar and navbar rhythm looks inconsistent.
metadata:
  argument-hint: "<file-or-directory-to-audit>"
  source: "plugins/tailwind/skills/spacing-audit/SKILL.md"
---

# Tailwind Spacing Audit & Refactor

Systematically detect and fix inconsistent spacing in Tailwind CSS v4+ layouts. The root
cause of most spacing bugs is **fragmented spacing authority** — multiple competing
mechanisms (gap, margin, padding, fixed widths) controlling the space between the same set
of visual peers.

Use `$ARGUMENTS` as the target scope. If `$ARGUMENTS` is empty, ask the user which
component or file to audit.

## Philosophy

Good spacing has one property: **a single source of truth per spacing relationship.** Every
pair of adjacent items should have exactly one class/mechanism determining the space between
them. When `gap-2` appears on a parent AND `me-1` on a child AND `ms-2` on a sibling, three
competing authorities produce visual noise.

The goal is never "make all numbers the same" — it's to ensure each spacing decision is
intentional, non-redundant, and traceable to one mechanism.

## Workflow

### Step 0: Detect Framework

Before auditing, detect the project's templating framework to determine which attribute
name and file globs to use throughout the audit.

Scan the project for template files:

- `*.tsx` / `*.jsx` — React (`className=`)
- `*.vue` — Vue (`class=`, `:class=`)
- `*.svelte` — Svelte (`class=`)
- `*.astro` — Astro (`class=`)
- `*.html` — plain HTML (`class=`)
- `*.erb` — Rails ERB (`class=`)
- `*.blade.php` — Laravel Blade (`class=`)

Use the detected attribute name(s) and file globs for all subsequent search commands. If
multiple frameworks are present, search across all of them.

For React projects, use `className=` in search patterns. For all other frameworks, use
`class=`. When both React and non-React templates exist, use `(class|className)=` to
match both.

### Step 1: Structural Audit

Before touching any code, read `references/heuristics.md` for the full detection checklist.
Scan the component and produce a **spacing map** — a brief annotation of every spacing
mechanism acting on the group of elements the user is concerned about:

```
[LinkedIn] --gap-1--> [Wrench] --gap-1--> [Babylon.js] --me-1+flex--> [Theme(me-2)]
            ^ parent gap                   ^ margin leak    ^ separate container
```

This makes fragmentation visible. Call out:
- How many distinct spacing mechanisms are active between visual peers
- Which items live in different containers but appear to be in the same visual group
- Any fixed widths (`w-*`) on items whose siblings are content-sized

### Step 2: Classify Anti-Patterns

Read `references/patterns.md` for the full catalog with before/after examples. The most
common patterns, in order of frequency:

1. **Container fragmentation** — Visually related items split across sibling containers
   with different spacing strategies. The #1 cause of "it looks uneven."
2. **Margin/gap mixing** — A flex parent uses `gap-*` but children also carry `m*-*`.
3. **Padding asymmetry** — Peer interactive elements with different `px-*` values.
4. **Fixed width on content-adaptive items** — One item has `w-24` while siblings size
   to content, creating uneven internal whitespace.
5. **Wrapper nesting** — Unnecessary `<div>` with flex alignment classes wrapping a single
   child, adding an extra layout level that obscures the true spacing. Uses `className`
   in React (`<div className="flex items-center">`) or `class` in other frameworks
   (`<div class="flex items-center">`).

### Step 3: Refactor

Apply these principles in order of priority:

**3a. Merge fragmented containers.** If items belong to the same visual group, place them
in the same flex container. One parent, one `gap-*` value. Remove outer margin classes
(`me-*`, `ms-*`) that were compensating for the split.

**3b. Choose one spacing authority per relationship.** Between any two adjacent items,
exactly one of these should be active — never more:
- `gap-*` on the parent (preferred for uniform spacing)
- Margin on a specific child (only for intentional exceptions)
- Padding inside the child (for internal spacing, not between-item spacing)

**3c. Standardize interactive element envelopes.** Buttons, links, and toggles that are
visual peers should share:
- The same height class (e.g., all `h-8` or all `h-12`)
- The same horizontal padding (e.g., all `px-2`)
- Content sizing (no `w-*` unless every peer also has the same fixed width)

**3d. Flatten unnecessary wrappers.** If a `<div>` wraps a single interactive child purely
for alignment, check whether the child can receive the alignment classes directly. Common
in navbars where each button got wrapped in a single-child alignment div during incremental
development.

**3e. Preserve intentional spacing breaks.** Not every spacing difference is a bug. A
visual separator (like a divider between nav groups) is intentional asymmetry. Ask before
normalizing something that might be a deliberate design choice.

### Step 4: Validate

After refactoring, re-draw the spacing map and confirm:
- [ ] Every pair of adjacent items has exactly one spacing authority
- [ ] All items in the same visual group share one parent container
- [ ] Interactive elements have consistent envelope classes
- [ ] No `w-*` on items that should be content-sized (unless all peers match)
- [ ] Hit targets (clickable area) are consistent across peer elements

## Tailwind v4 Specifics

Tailwind v4 changed how spacing works in important ways:

- `gap-*` is the canonical way to space flex/grid children. Prefer it over margins.
- Arbitrary values use `gap-[12px]` syntax if the scale doesn't have what's needed, but
  prefer scale values (`gap-1` = 4px, `gap-2` = 8px, `gap-3` = 12px, `gap-4` = 16px).
- `space-x-*` and `space-y-*` still exist but are margin-based under the hood. Prefer
  `gap-*` for new code; flag `space-*` as a migration opportunity when found alongside
  `gap-*`.
- CSS logical properties: `me-*` (margin-inline-end) and `ms-*` (margin-inline-start)
  replace `mr-*`/`ml-*` in LTR/RTL-aware code. The anti-pattern is the same regardless
  of physical vs logical naming.

## Output Format

When presenting findings:

1. **Spacing map** — The visual annotation showing current spacing mechanisms
2. **Anti-patterns found** — Numbered list with pattern name and specific elements involved
3. **Proposed refactor** — The actual code change, shown as a focused diff or before/after.
   Only change spacing-related classes; don't rewrite unrelated markup.
4. **Validation checklist** — The Step 4 checklist filled in for the refactored code

When the fix is straightforward, collapse steps 1-4 into a concise explanation + code.
Don't over-formalize simple cases.

## Reference Files

For detailed detection logic and worked examples, consult:

- **`references/heuristics.md`** — Seven detection heuristics (H1-H7) with Tailwind class
  patterns and search commands for codebase-wide scanning
- **`references/patterns.md`** — Anti-pattern catalog with before/after examples for each
  pattern, plus a quick decision tree for diagnosing spacing issues

## What This Skill Does NOT Cover

- Color, typography, or non-spacing visual design
- Responsive breakpoint strategy (though spacing changes should preserve existing breakpoints)
- Component API design or prop architecture
- Tailwind config or theme customization
- Animation or transition timing


## 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.

Attribution

tonytony
View sourceSee grades on GitHubMore from tony →
SSkills DirectorySkills Directory

Ship a skill? Prove it's safe.

Free 120-pattern security scan, letter grade, and an embeddable README badge.

Submit a skill

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments (0)

No comments yet. Be the first to comment!

SSkills DirectorySkills Directory

Ship a skill? Prove it's safe.

Free 120-pattern security scan, letter grade, and an embeddable README badge.

Submit a skill

Related Skills

Caveman

Terse caveman voice: answer first, fluff gone, every technical fact kept. Use for /caveman, "caveman mode", "talk like caveman", "be brief", "less tokens". Stays on until "stop caveman" or "normal mode".

1100021 votes

Hyperplan

Adversarial multi-agent planning skill. Self-orchestrates 5 hostile category members (unspecified-low, unspecified-high, deep, ultrabrain, artistry) via team-mode for ruthless cross-critique debate, distills only the defensible insights, then MANDATORILY hands the distilled insight bundle to the `plan` agent for executable plan formalization. Use when planning needs maximum rigor and surfacing of weak assumptions, blind spots, and over-engineering. Triggers: 'hyperplan', 'hpp', '/hyperplan', ...

698621 votes

Writing Skills

Create and manage Claude Code skills in HASH repository following Anthropic best practices. Use when creating new skills, modifying skill-rules.json, understanding trigger patterns, working with hooks, debugging skill activation, or implementing progressive disclosure. Covers skill structure, YAML frontmatter, trigger types (keywords, intent patterns), UserPromptSubmit hook, and the 500-line rule. Includes validation and debugging with SKILL_DEBUG. Examples include rust-error-stack, cargo-dep...

3931 votes

Mcp Code Execution

Routes multi-tool workflows through MCP servers for large datasets and pipelines. Use when Bash tool overhead is limiting throughput on data-heavy tasks.

3421 votes

catchup

Recovers the conversation and failed tool calls of a previous Codex, Amp, Claude Code, Antigravity, Cline, Copilot CLI, Cursor, DeepSeek Harness, Grok Build, Kimi, OpenCode, Pi Agent, or ZCode session. Use when the user says "catch up", "what did the last session do", "get me up to speed", "I switched agents", asks to recover/summarize a previous session before continuing, or asks to diagnose or report a catchup failure. Do NOT use for the current conversation, git history, or any non-agent log.

741 votes
View all in ai-agents →