Repository navigation
skills: add bulk-css-operation for safe CSS pruning, refactoring diffs, and rule locations - #10
Merged
Merged
Conversation
… move skill to /skills
…on for 3-tier coverage pruning
…gn vocabulary across verification scripts
…ten skill description
…move machine-specific paths
…browser discovery
…live test with modern css edge cases
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Clean up unused CSS, refactor stylesheets with automated safety checks, and read exact character offsets from standard CSSOM rule objects.
What You Can Do
1. Prune unused CSS safely using real Chrome coverage
Point a CLI command or script at a live URL or HTML file to produce a cleaned stylesheet that strips unused classes while protecting foundational and interactive styling:
:root,html,body,@property,@layerdeclarations,@charset, and@importeven if static coverage reports 0% hits.@media print,@media (prefers-color-scheme: dark),@media (prefers-reduced-motion), and@starting-styletransitions.:hover,:focus-visible, and:activerules when the underlying element is present in the DOM.@keyframesanimations and@font-facerules when they are referenced by active declarations./* @cssom-review: <reason> */so changes can be audited directly ingit diff.2. Safely split, bundle, and migrate CSS files
Refactor CSS—such as splitting monolithic files into modules, flattening nesting, or migrating colors to CSS custom properties—and automatically verify that no styles or cascade relationships broke:
diffCssAst): Verifies that no selectors, properties, or!importantflags were unintentionally dropped, added, or modified when moving rules between files.checkCascadeConflicts): Detects source-order reversals between rules that target overlapping selectors at identical specificity, catching accidental precedence flips when reordering files.diffCascadedStyles): Compares element-level cascaded values before and after refactoring on sample DOM elements to guarantee visual equivalence when renaming classes or restructuring selectors.3. Inspect character offsets on parsed CSS rules
Read exact character offsets from the original source text directly on standard
CSSRuleinstances:rule.location: Returns{ start, end, bodyStart?, bodyEnd? }containing 0-based character offsets for any rule, at-rule, or nested block.Changed Files & Tests
src/rules/base.ts,src/parser.ts,src/types.ts,src/index.ts: Addedlocationgetter toCSSRuleand token offset calculation during parsing.skills/bulk-css-operation/scripts/coverage-prune.ts: Pruning engine that strips unused CSS based on coverage data while retaining foundational tokens and assets.skills/bulk-css-operation/scripts/live-coverage-collector.ts: Runs headless Chrome via Puppeteer to collect live CSS coverage.skills/bulk-css-operation/scripts/run-coverage-prune.ts: CLI entry point for pruning a local HTML file or web URL.skills/bulk-css-operation/scripts/ast-diff.ts,cascade-diff.ts,cascaded-diff.ts: Verification utilities checking AST equality, cascade conflicts, and element-level cascaded styles.skills/bulk-css-operation/SKILL.md: Playbook and documentation for bulk CSS refactoring workflows.tests/rule-location.test.ts: Unit tests verifying location offsets across style rules, at-rules, nested rules, and edge cases.skills/bulk-css-operation/scripts/*.test.ts: Unit and integration tests covering live headless Chrome coverage pruning, AST diffing, and cascade verification.