css-specificity
โCleanAnalyze CSS specificity in a project, detect conflicts, flag unnecessary !important usage, and suggest corrections. Use when reviewing CSS code quality, debugging style overrides, auditing stylesheets, or when a user asks to check their CSS specificity, find CSS conflicts, simplify selectors, or clean up !important usage. Triggers on tasks involving .css files where specificity or selector quality is relevant.
Install Command
npx skills add handxr/css-specificity-skillSKILL.md
--- name: css-specificity description: Analyze CSS specificity in a project, detect conflicts, flag unnecessary !important usage, and suggest corrections. Use when reviewing CSS code quality, debugging style overrides, auditing stylesheets, or when a user asks to check their CSS specificity, find CSS conflicts, simplify selectors, or clean up !important usage. Triggers on tasks involving .css files where specificity or selector quality is relevant. --- # CSS Specificity Analyzer Analyze CSS files for specificity issues, detect conflicts between rules, and suggest concrete improvements. Conservative approach: report and suggest, never auto-apply changes. ## Workflow 1. Locate `.css` files in the project using Glob (`**/*.css`) 2. Run the analyzer script (path relative to this skill's directory): ```bash python3 PATH_TO_SKILL/scripts/css_specificity_analyzer.py <file_or_dir> --json ``` Replace `PATH_TO_SKILL` with the absolute path to the directory containing this SKILL.md. 3. Parse the JSON output 4. Present findings grouped by severity (errors first, then warnings) 5. For each issue, show the selector, line number, current specificity, and a concrete suggestion 6. Wait for user approval before applying any changes ## Running the Analyzer ```bash # Single file python3 PATH_TO_SKILL/scripts/css_specificity_analyzer.py styles.css --json # Entire directory python3 PATH_TO_SKILL/scripts/css_specificity_analyzer.py src/ --json # Custom threshold (default 30, flag selectors scoring >= this) python3 PATH_TO_SKILL/scripts/css_specificity_analyzer.py src/ --json --threshold 20 ``` ## Interpreting Results The JSON report contains four sections: - **summary**: Total selectors, average/max specificity, !important count, conflict count, warning/error counts - **selectors**: Only selectors with issues (includes specificity, score, severity, and suggestion) - **conflicts**: Pairs of rules with large specificity gaps targeting the same CSS property - **importants**: Each `!important` usage with assessment of whether it masks a conflict or is unnecessary ## Presenting Suggestions Propose specific rewrites with before/after specificity (e.g., "Replace `#header .nav a` with `.nav-link`"). For common anti-patterns and concrete fix examples, read [references/specificity-rules.md](references/specificity-rules.md). ## Applying Corrections Only apply corrections after user approval. Apply one change at a time, re-run the analyzer after each batch, and never introduce new specificity issues while fixing existing ones.
Similar Skills
Complete Tailwind CSS documentation. Use when working with Tailwind CSS utility classes, responsive design, dark mode, animations, custom configurations, plugins, or styling questions. Covers all utility classes, modifiers, configuration options, and best practices.
npx skills add leonaaardob/lb-tailwindcss-skillAnalyze, plan, review, and optimize any codebase across 4 modes: Discovery (understand architecture and risks), Review (validate changes and detect breaking changes), Optimization (find bottlenecks and vulnerabilities), Implementation Planning (generate step-by-step guidance). Works with React, Django, Rails, Go, Rust, and 30+ frameworks. Use when analyzing codebase structure, assessing feature safety, finding security issues, planning implementations, or discovering performance problems.
npx skills add baagad-ai/code-surgeonPerform security audits on code changes, diffs, or branches to find high-confidence exploitable vulnerabilities. Use when asked to "audit security", "review for vulnerabilities", "security scan", "check for security issues", "audit this PR", "review these changes for security", or "find vulnerabilities in diff". Distinct from security-review (which provides secure coding patterns/checklists) รขยย this skill actively audits code changes using a structured methodology with false positive filtering. Includes Python scripts for GitHub Action CI integration and PR evaluation.
npx skills add LeonMelamud/claude-code-security-reviewUse when setting up or configuring code quality tools (formatters, linters, type checkers, dependency scanners) for a repository. Also use when adding visual accessibility automation or security baseline scanning. Do not use for general coding or when tools are already configured.
npx skills add metyatech/skill-code-quality-setup