Delete Content Skill
Generic file deletion Skill that checks RULE.md permissions and handles dependencies safely.
When to use this Skill
- •User says "delete", "remove", "trash"
- •User requests content deletion
- •User wants to clean up old files
Workflow
1. Identify Target File
If user provides file path:
- •Verify file exists using
lsor Read - •Confirm file identity
If user provides topic/title only:
- •Search for file using Grep or Glob
- •Pattern:
**/*keyword*.md - •If multiple matches: present list, ask user to choose
- •If no matches: report not found
Search strategies:
- •Filename match:
find . -name "*keyword*" - •Content match:
grep -r "keyword" . - •README.md index: Search README.md files for references
2. Read Directory RULE.md
Locate and read RULE.md:
- •Check file's directory for RULE.md
- •If not found, check parent directories (inheritance)
- •Parse RULE.md for deletion rules
Check for:
- •Are deletions allowed? (some directories may be immutable or archive-only)
- •Archive-instead rules (move to archive instead of delete)
- •Backup requirements (create backup before delete)
- •Dependency rules (check cross-references)
- •Confirmation requirements
Example RULE.md deletion rules:
## Deletion Rules - Deletions allowed with confirmation - Check for cross-references before deleting - Move to Archive/ subdirectory instead of permanent deletion
3. Check Dependencies
Search for cross-references:
- •Use Grep to find links to this file:
grep -r "filename" . - •Search for references in README.md files
- •Check for reverse links (files this file links to)
- •Identify files that depend on this content
Categorize dependencies:
- •Incoming: Files that link to this file (will break if deleted)
- •Outgoing: Files this file links to (won't break, but orphans references)
- •Bidirectional: Cross-referenced files (mutual dependencies)
Severity assessment:
- •Critical: Many incoming links, part of important workflow
- •Warning: Some incoming links, moderately used
- •Low: Few or no dependencies
4. User Confirmation
Present deletion summary:
⚠️ Delete confirmation required File: [path to file] Size: [file size] Last modified: [timestamp] Dependencies found: - [file1.md] links to this file - [file2.md] links to this file (Total: X files reference this content) RULE.md policy: [deletion policy summary] Are you sure you want to delete this file? - Yes, delete permanently - Yes, move to archive (if RULE.md allows) - No, cancel - Show me the dependencies first
If user requests dependency review:
- •Show each file that references this content
- •Show the context (line where reference appears)
- •Allow user to reconsider
5. Execute Deletion
Based on RULE.md policy:
Permanent deletion:
rm [file path]
- •Only if RULE.md allows or user explicitly overrides
- •Use Bash tool with rm command
- •Verify deletion successful
Archive instead:
# Create archive directory if not exists mkdir -p Archive/ # Move file to archive mv [file path] Archive/[filename]
- •Follow RULE.md archive structure
- •Preserve filename or add timestamp
- •Update archive README.md
Backup then delete:
# Create backup cp [file path] [backup path] # Then delete original rm [file path]
- •Create backup per RULE.md specification
- •Verify backup successful before deleting
6. Governance Update
Update README.md:
- •Read current README.md
- •Find entry for deleted file
- •Remove entry from file list
- •Add to "Recent Changes" section:
markdown
- YYYY-MM-DD: Removed filename.md
- •Update "Last updated" timestamp
- •Save README.md
Update parent README.md if needed:
- •If directory now empty, update parent
- •Note directory is empty or removed
Handle cross-references:
- •Update files that referenced deleted content (if possible)
- •Or add note in README.md: "Files with broken references: [list]"
- •Offer to update broken links
Verify cleanup:
- •Ensure no orphaned references
- •Check README.md is valid markdown
- •Confirm directory structure intact
7. Report to User
Confirm deletion complete:
✅ File deleted successfully Deleted: [path to file] Method: [permanent deletion / moved to archive / backed up then deleted] README.md updated: - [directory]/README.md Dependencies handled: - [X] files need attention (broken links) - [List of affected files] Recommendation: Review affected files to update/remove broken links
If archived instead:
✅ File archived successfully Original: [original path] Archived to: [archive path] Archive method: [per RULE.md policy] README.md updated: - [directory]/README.md - Archive/README.md Note: File preserved in archive, not permanently deleted
Special Cases
Immutable Directory
If RULE.md specifies immutable:
## RULE.md says: "This directory is immutable - no deletions allowed"
Process:
- •Warn user: "RULE.md indicates this directory should not have deletions"
- •Explain policy reasoning
- •Ask: "Do you want to override this rule?"
- •If yes: proceed with deletion and log rule override
- •If no: cancel operation
Archive-Only Policy
If RULE.md requires archival instead:
## RULE.md says: "Move to Archive/ instead of deleting"
Process:
- •Don't offer permanent deletion
- •Execute archive operation
- •Update both original and archive README.md
- •Report archive location
Batch Deletion
If user requests deleting multiple files:
User: "Delete all old notes from last year"
Process:
- •Identify all matching files
- •Check each file's RULE.md
- •Check dependencies for each
- •Present summary: "X files match, Y have dependencies"
- •Request batch confirmation
- •Execute deletions one by one
- •Report summary of all deletions
Directory Deletion
If user wants to delete entire directory:
User: "Delete the old-project directory"
Process:
- •Read directory RULE.md for deletion rules
- •Check parent directory RULE.md for subdirectory rules
- •Scan all files in directory for external dependencies
- •Present comprehensive summary
- •Warn: "This will delete X files and Y subdirectories"
- •Request explicit confirmation
- •Execute recursive deletion or archive
- •Update parent README.md
Soft Delete (Mark as Deleted)
If RULE.md specifies soft delete:
## RULE.md says: "Mark files as deleted in frontmatter instead of removing"
Process:
- •Don't delete file physically
- •Update frontmatter:
status: deleted - •Update README.md: mark as
[DELETED] filename.md - •File stays but marked as obsolete
Error Handling
File Not Found
User: "Delete the transformer note" → Search for file → No matches found → Report: "I couldn't find a file about transformers. Nothing to delete."
Multiple Matches
User: "Delete the transformer note" → Find 3 files with "transformer" → Present list: "I found 3 files. Which one to delete?" → User selects → Proceed
RULE.md Forbids Deletion
RULE.md says: "Immutable directory" → Warn: "RULE.md forbids deletions in this directory" → Explain reasoning → Ask for override confirmation → If confirmed: proceed with warning note
High-Impact Dependencies
File has 50+ incoming references → Warn: "⚠️ HIGH IMPACT: 50+ files reference this content" → Show most critical dependencies → Recommend: "Consider archiving instead of deleting" → Require explicit "yes, delete anyway" confirmation
Deletion Fails
Bash rm command fails (permissions, file locked, etc.) → Report error clearly → Show exact error message → Suggest: "Check file permissions or if file is open in another program" → Offer alternatives: archive, rename, mark as deleted
Broken References After Deletion
Deletion successful but broken links remain → Report: "Deletion complete, but broken references detected in:" → List affected files → Offer: "Would you like me to update these files to remove broken links?" → If yes: update files to remove/fix references
Integration with Governance
This Skill automatically invokes the governance protocol:
Before deletion:
- •Locate and read RULE.md
- •Validate deletion is allowed
- •Check dependency policy
During deletion:
- •Follow RULE.md deletion method (delete, archive, backup)
- •Execute safely
After deletion:
- •Update README.md
- •Handle broken references
- •Verify cleanup complete
Examples
Example 1: Simple Deletion
User: "Delete the old transformer draft"
Skill workflow:
- •Searches for file → Finds
Research/AI/2025-10-15-transformer-draft.md - •Reads Research/AI/RULE.md → Deletions allowed with confirmation
- •Checks dependencies → No references found
- •Asks confirmation: "Delete transformer-draft.md? No dependencies found."
- •User confirms
- •Executes
rm Research/AI/2025-10-15-transformer-draft.md - •Updates Research/AI/README.md (removes entry)
- •Reports: "✅ Deleted transformer-draft.md"
Example 2: Archive Instead
User: "Delete the 2024 work logs"
Skill workflow:
- •Finds Work/WorkLog/2024/ directory
- •Reads Work/WorkLog/RULE.md → "Move old logs to Archive/ instead of deleting"
- •Checks dependencies → Some cross-references to meeting notes
- •Presents: "Found 2024 logs (52 files). RULE.md policy: archive instead of delete"
- •User confirms
- •Creates
Work/WorkLog/Archive/2024/if not exists - •Executes
mv Work/WorkLog/2024/* Work/WorkLog/Archive/2024/ - •Updates README.md files
- •Reports: "✅ Archived 52 log files to Archive/2024/"
Example 3: High-Impact Deletion
User: "Delete the core-concepts document"
Skill workflow:
- •Finds
Research/core-concepts.md - •Reads Research/RULE.md → Deletions allowed
- •Checks dependencies → 25 files reference this document
- •Warns: "⚠️ HIGH IMPACT: 25 files reference core-concepts.md"
- •Shows first 5 most critical dependencies
- •Recommends: "This is a foundational document. Consider archiving instead?"
- •User still chooses delete
- •Asks: "Are you absolutely sure? Type 'delete core-concepts' to confirm"
- •User confirms
- •Executes deletion
- •Updates README.md
- •Reports broken references: "25 files need attention"
- •Offers to help fix broken links
Best Practices
- •Always check dependencies - Prevent broken knowledge base
- •Read RULE.md first - Respect deletion policies
- •Archive when possible - Preserve content instead of permanent deletion
- •Confirm before deleting - No accidental deletions
- •Update README.md immediately - Keep index accurate
- •Handle broken links - Offer to fix cross-references
- •Report clearly - User should know what was deleted and impact
- •Follow RULE.md policies - Even if user requests override
Notes
- •This Skill works with any directory structure by reading RULE.md
- •Checks for dependencies to prevent broken knowledge base
- •Offers archival as safer alternative to permanent deletion
- •Always requires confirmation for destructive operations
- •Maintains README.md index integrity
- •Works in parallel with CLAUDE.md subagents
- •Never deletes RULE.md files (requires explicit governance agent action)