Skip to content

feat: added new deco block cleanup skill#10

Open
aline-pereira wants to merge 1 commit into
mainfrom
feat/block-cleanup
Open

feat: added new deco block cleanup skill#10
aline-pereira wants to merge 1 commit into
mainfrom
feat/block-cleanup

Conversation

@aline-pereira

@aline-pereira aline-pereira commented May 15, 2026

Copy link
Copy Markdown

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-cleanup skill and an audit script to find and safely remove unused .deco blocks in deco.cx storefronts, reducing repo noise and deploy time.

  • New Features

    • New block-cleanup skill with a simple workflow: audit → review → delete.
    • Python auditor (scripts/audit-blocks.py) that reports: orphan sections, legacy/test blocks, inactive A/B matchers (traffic 0 or 1/100%), and duplicate redirects.
    • Updated README with a Maintenance section referencing this skill.
  • Migration

    • Run the audit: 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

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant