with one click
css-append-selector-verify
Safely append CSS styles from one file to another, with per-selector grep verification after every append to catch silent truncation that tail or wc-l alone would miss
Menu
Safely append CSS styles from one file to another, with per-selector grep verification after every append to catch silent truncation that tail or wc-l alone would miss
| name | css-append-selector-verify |
| description | Safely append CSS styles from one file to another, with per-selector grep verification after every append to catch silent truncation that tail or wc-l alone would miss |
This skill provides a systematic approach for safely appending CSS styles from a source file to a destination file. The workflow ensures no content is overwritten, CSS variables are properly adapted, and every appended selector is individually confirmed present — so silent heredoc truncation of long lines is caught immediately rather than being masked by a passing line-count check.
First, examine the source CSS file to identify the selectors and rules you want to transfer:
# Read the source CSS file
cat /path/to/source/styles.css
# Identify specific selectors if needed
grep "selector-pattern" /path/to/source/styles.css
Document:
.panel-tab, .header-nav)--primary-color, --spacing-unit)Examine the destination file to understand existing rules and avoid duplication:
# Read the destination CSS file
cat /path/to/destination/styles.css
# Check if specific selectors already exist
grep "selector-name" /path/to/destination/styles.css
# Check for existing CSS variables
grep "^[[:space:]]*--" /path/to/destination/styles.css | head -20
Identify:
Compare source and destination to determine:
Example variable mapping:
Source: --panel-bg → Destination: --background-secondary
Source: --text-primary → Destination: --color-text-primary
Source: --border-radius → Keep as-is (if already defined in destination)
Create the CSS content to append, adapting variables as needed:
/* Example adapted CSS */
.new-selector {
background-color: var(--background-secondary); /* was --panel-bg */
color: var(--color-text-primary); /* was --text-primary */
border-radius: var(--border-radius); /* unchanged */
padding: 8px 16px;
}
.existing-selector {
/* Only add missing properties, not the entire rule */
new-property: value;
}
Use append operations (never overwrite) to add the new styles.
Record the line count BEFORE appending (use this in step 6):
BEFORE=$(wc -l < /path/to/destination/styles.css)
Then append:
cat >> /path/to/destination/styles.css << 'EOF'
/* Added styles from source project */
.selector-name {
property: value;
variable-property: var(--adapted-variable);
}
EOF
Best practices:
>> (append) never > (overwrite)Confirm that the styles were added correctly. Do not rely on tail or wc -l alone — a heredoc can silently truncate an overly long line, leaving a selector block incomplete while the line count still increases. The required approach is to grep for every selector that was just appended.
AFTER=$(wc -l < /path/to/destination/styles.css)
echo "Lines added: $((AFTER - BEFORE))"
# Repeat for every selector appended in step 5
grep -n "\.selector-name" /path/to/destination/styles.css || echo "MISSING: .selector-name"
grep -n "\.another-selector" /path/to/destination/styles.css || echo "MISSING: .another-selector"
If any grep prints "MISSING", the append was incomplete — re-run step 5.
If many selectors were appended, use a loop:
DEST=/path/to/destination/styles.css
MISSING=0
for selector in \
".selector-name" \
".another-selector" \
".yet-another"; do
if ! grep -q "$selector" "$DEST"; then
echo "MISSING SELECTOR: $selector"
MISSING=$((MISSING + 1))
fi
done
if [ "$MISSING" -gt 0 ]; then
echo "ERROR: $MISSING selector(s) not found — append may have been truncated."
exit 1
else
echo "All selectors verified present."
fi
tail -n 30 /path/to/destination/styles.css
Why per-selector grep is required:
wc -l increments even when a line is truncated — the count passes but content is lost.tail shows recent lines but only reveals truncation if you happen to notice a cut-off line visually.grep for each selector name fails with a non-zero exit code if the selector is absent, making the failure explicit and automatable.Here's a full example workflow:
# 1. Read source CSS and identify target
cat project-a/components.css | grep -A 10 ".button-primary"
# 2. Check destination for conflicts
grep ".button-primary" project-b/main.css
grep "^[[:space:]]*--btn-" project-b/main.css
# 3. Identify that .button-primary is missing, and variables need mapping:
# --btn-color → --primary-color (exists in destination)
# --btn-padding → create inline value
# 4. Record line count before append
BEFORE=$(wc -l < project-b/main.css)
# 5. Append adapted styles
cat >> project-b/main.css << 'EOF'
/* Button styles from project-a */
.button-primary {
background-color: var(--primary-color);
padding: 10px 20px;
border-radius: 4px;
font-weight: 600;
}
EOF
# 6a. Line-count delta
AFTER=$(wc -l < project-b/main.css)
echo "Lines before: $BEFORE | Lines after: $AFTER | Added: $((AFTER - BEFORE))"
# 6b. Per-selector grep — catches truncation that wc -l and tail miss
grep -n "\.button-primary" project-b/main.css \
&& echo "OK: .button-primary" \
|| echo "MISSING: .button-primary — possible truncation!"
# 6c. Visual spot-check
tail -n 10 project-b/main.css
>>, never >tail and wc -l do not detect mid-block truncationwc -l before and after as a supplementary sanity check, but never as the sole verificationcat tmpfile >> dest.css rather than a heredoc; then grep-verify as normalDelegate tasks to OpenSpace — a full-stack autonomous worker for coding, DevOps, web research, and desktop automation, backed by an extensive MCP tool and skill library. Skills auto-improve through use, reducing token consumption over time. A cloud community lets agents share and collectively evolve reusable skills.
Incremental audio production with duration mismatch handling, adaptive stem extension, and pre-mix alignment verification
Audio production with diagnostic analysis, timecode parsing from documents, and verified export workflow
Incremental audio production with duration alignment handling, per-stem verification, and adaptive extension strategies
Step-by-step audio production with per-stem verification, timing alignment, and incremental quality gates
End-to-end audio production workflow with stems, effects, archiving, and verification