feat: added new deco block cleanup skill#10
Open
aline-pereira wants to merge 1 commit into
Open
Conversation
Contributor
There was a problem hiding this comment.
2 issues found across 3 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name=".claude-deco/skills/block-cleanup/scripts/audit-blocks.py">
<violation number="1" location=".claude-deco/skills/block-cleanup/scripts/audit-blocks.py:139">
P2: Duplicate-redirect detection can produce false positives by counting repeated rules from the same block as multiple blocks.</violation>
<violation number="2" location=".claude-deco/skills/block-cleanup/scripts/audit-blocks.py:204">
P2: The final candidate total excludes duplicate redirects, so the summary underreports detected issues.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
Re-trigger cubic
| print(" No duplicate redirects found.") | ||
|
|
||
| # Summary | ||
| total_candidates = len(orphan_sections) + len(legacy_blocks) + len(inactive_ab) |
Contributor
There was a problem hiding this comment.
P2: The final candidate total excludes duplicate redirects, so the summary underreports detected issues.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At .claude-deco/skills/block-cleanup/scripts/audit-blocks.py, line 204:
<comment>The final candidate total excludes duplicate redirects, so the summary underreports detected issues.</comment>
<file context>
@@ -0,0 +1,213 @@
+ print(" No duplicate redirects found.")
+
+ # Summary
+ total_candidates = len(orphan_sections) + len(legacy_blocks) + len(inactive_ab)
+ print(f"\n{'='*70}")
+ print(f" TOTAL REMOVAL CANDIDATES: {total_candidates}")
</file context>
Suggested change
| total_candidates = len(orphan_sections) + len(legacy_blocks) + len(inactive_ab) | |
| total_candidates = len(orphan_sections) + len(legacy_blocks) + len(inactive_ab) + len(duplicate_redirects) |
| for rule in b['data'].get('redirects', []) if isinstance(b['data'].get('redirects'), list) else []: | ||
| to = rule.get('to', '') | ||
| if to: | ||
| redirect_by_dest[to].append(b) |
Contributor
There was a problem hiding this comment.
P2: Duplicate-redirect detection can produce false positives by counting repeated rules from the same block as multiple blocks.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At .claude-deco/skills/block-cleanup/scripts/audit-blocks.py, line 139:
<comment>Duplicate-redirect detection can produce false positives by counting repeated rules from the same block as multiple blocks.</comment>
<file context>
@@ -0,0 +1,213 @@
+ for rule in b['data'].get('redirects', []) if isinstance(b['data'].get('redirects'), list) else []:
+ to = rule.get('to', '')
+ if to:
+ redirect_by_dest[to].append(b)
+ duplicate_redirects = {
+ dest: blocks_list
</file context>
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.
Adds the block-cleanup skill to help audit and remove unnecessary .deco blocks in deco.cx/storefront projects.
Over time, deco.cx projects accumulate blocks in .deco/blocks/ that are no longer used — increasing repository size, slowing deploys, and adding noise to the CMS. This skill provides a structured workflow and an automated audit script to identify and safely remove them.
Files
SKILL.md — skill definition with step-by-step workflow: audit → manual review → deletion
scripts/audit-blocks.py — Python script that scans .deco/blocks/ and produces a categorized report
Audit categories
Orphan sections — blocks not referenced as __resolveType in any page
Legacy/Test blocks — blocks with suspicious names (test, legacy, backup, old, bkp, example)
Inactive A/B matchers — website/matchers/random.ts blocks with traffic=0 or traffic=100
Duplicate redirects — multiple redirect blocks pointing to the same destination
Usage
python3 scripts/audit-blocks.py /path/to/project
The script outputs a full text report with all candidates. Manual review is recommended before deleting — orphan blocks may still be used via API or dynamic context.
Summary by cubic
Adds the
block-cleanupskill and an audit script to find and safely remove unused.decoblocks in deco.cx storefronts, reducing repo noise and deploy time.New Features
block-cleanupskill with a simple workflow: audit → review → delete.scripts/audit-blocks.py) that reports: orphan sections, legacy/test blocks, inactive A/B matchers (traffic 0 or 1/100%), and duplicate redirects.Migration
python3 scripts/audit-blocks.py /path/to/project, then review results before deleting files.Written for commit bcde1f8. Summary will update on new commits. Review in cubic