TODO.sh - Convert TODO Comments to GitHub Issues
Overview
The todo.sh script automatically extracts TODO/FIXME/XXX/HACK comments from Swift files and creates corresponding GitHub issues. It includes duplicate detection and tracking to prevent creating multiple issues for the same TODO.
Quick Start
# Preview what issues would be created (RECOMMENDED FIRST)
./todo.sh --dry-run
# Create issues for all unprocessed TODOs
./todo.sh
# Use custom labels
./todo.sh --label tech-debt
# Verbose output for debugging
./todo.sh --dry-run --verboseCurrent Status
TODOs in Codebase: 47 TODO comments across 40 Swift files
Example TODOs Found:
AlertView.swift:62 - CHECK HISTORY OF THIS COMMIT
AppSources/VIEWS/JOURNAL/SettingsSheetView.swift:194 - NEED TO FIND STATUS VIEW IN CODEBASE
CHAT/MessageCardContainer.swift:236 - YES, YES, YES, YES - THIS IS THE UI I WANT, NEED TO KEEP AND INTEGRATE
CoreUIViews/FlippableCard.swift:119 - THIS MUST BE USED
CreateHome/JournalDescriptionView.swift:457 - THIS NEEDS PRIORITY ONE ATTENTION
Features
ā Implemented
[x] Extracts TODO/FIXME/XXX/HACK comments from Swift files
[x] Creates one GitHub issue per TODO comment
[x] Hash-based duplicate detection
[x] Local tracking file (.todo-tracker.json) to prevent re-creating issues
[x] GitHub API duplicate checking via gh CLI
[x] Dry-run mode for previewing issues before creation
[x] Custom label support (default: todo, auto-generated)
[x] Verbose mode for debugging
[x] Direct links to code in issue body
[x] Rate limiting (1 second between issue creations)
[x] Comprehensive error handling
[x] Prerequisite validation (gh CLI, git repo, authentication)
Issue Format
Each created issue includes:
### TODO Comment
**File:** `path/to/file.swift`
**Line:** 123
**Hash:** `abc123...` (for duplicate detection)// TODO: The actual TODO comment from the code
---
š [View in code](../../blob/main/path/to/file.swift#L123)
*Auto-generated from TODO comment by todo.sh*Usage Examples
Basic Usage
# 1. First, preview what will be created
./todo.sh --dry-run
# 2. Review the output, then create issues
./todo.sh
# 3. View created issues on GitHub
gh issue list --label todoCustom Labels
# Replace default labels with custom ones
./todo.sh --label tech-debt
# Add multiple labels
./todo.sh --label todo --label priority-high --label needs-reviewDebugging
# See detailed processing information
./todo.sh --dry-run --verbose
# Check tracking file
cat .todo-tracker.json | jq .How It Works
1. TODO Detection
The script uses git grep to find TODO patterns:
git grep -n -E "(TODO|FIXME|XXX|HACK)[\s:(\[]" -- "*.swift"Supported Formats:
// TODO: Description
//TODO Description (no space)
// FIXME: Problem
// XXX: Critical issue
// HACK: Temporary solution
2. Duplicate Prevention
Two-layer approach:
1. Local tracking - Checks .todo-tracker.json for previously processed TODOs
2. GitHub API check - Queries GitHub for existing open issues with the same hash
Hash Generation: md5(filepath:line_number:todo_text_first_50_chars)
This ensures:
TODOs that haven't changed won't create duplicate issues
You can run the script multiple times safely
Works across different machines (via GitHub API check)
3. Issue Creation
Uses the GitHub CLI (gh) to create issues:
gh issue create \
--title "TODO: Description" \
--body "..." \
--label "todo" \
--label "auto-generated"Files
todo.sh - Main script (14KB)
.todo-tracker.json - Local tracking file (gitignored)
TODO_SH_USAGE.md - This documentation
Tracking File Format
.todo-tracker.json stores processed TODOs:
{
"todos": [
{
"hash": "abc123...",
"issue_number": "42",
"file": "/path/to/file.swift",
"line": "123",
"created_at": "2025-04-28T10:30:00Z"
}
]
}Note: This file is in .gitignore to prevent merge conflicts and allow per-developer tracking.
Prerequisites
Required
1. GitHub CLI (gh) - Install here
# macOS
brew install gh
# Authenticate
gh auth login2. Git repository - Must be run from within a git repository
3. GitHub authentication - gh auth status should show you're logged in
Optional
jq - For pretty-printing the tracking file (not required for script operation)
Edge Cases & Limitations
Multi-line TODOs
Currently, each TODO line creates a separate issue:
// TODO: This is part 1
// This is part 2 <- Creates a second issueWorkaround: Write TODOs on a single line, or manually consolidate issues after creation.
TODO Text Extraction
Some edge cases in text extraction:
// TODO: coordinates: (0.0, 0.0) // TODO: Add real coordinatesThis creates an issue with the full line. Consider editing the title manually on GitHub if needed.
Line Number Changes
If a TODO moves to a different line (e.g., after adding code above it), the hash changes and a new issue will be created. The old issue remains open.
Recommendation: Close the old issue manually and reference the new one, or avoid running the script frequently during active development.
Troubleshooting
"GitHub CLI is not authenticated"
gh auth loginFollow the prompts to authenticate.
"Cannot detect GitHub repository"
Make sure you're in a directory with a GitHub remote:
git remote -v"sed: RE error: parentheses not balanced"
This was fixed by switching to perl for text extraction. If you see this error, make sure you're using the latest version of todo.sh.
No TODOs Found
# Manually check for TODOs
git grep -E "(TODO|FIXME|XXX|HACK)" -- "*.swift"If you see TODOs but the script doesn't find them, they may not match the expected pattern. Ensure they have a space or colon after the keyword.
Integration with GitHub
View All TODO Issues
gh issue list --label todoClose a TODO Issue
gh issue close <issue-number> --comment "Resolved in commit abc123"Search TODO Issues
gh issue list --label todo --search "in:title SPECIFIC_TEXT"Future Enhancements
Potential additions (not currently implemented):
[ ] --close-resolved flag to automatically close issues when TODOs are removed
[ ] Multi-line TODO consolidation
[ ] TODO metadata parsing (author, date, priority)
[ ] GitHub Actions workflow for automated TODO tracking on push
[ ] Support for other file types (Kotlin, TypeScript, etc.)
[ ] Project board integration
[ ] Assignee support based on git blame
Best Practices
1. Run with --dry-run first - Always preview before creating issues
2. Clean up old TODOs - Remove resolved TODOs from code promptly
3. Write descriptive TODOs - The TODO text becomes the issue title
4. Use consistent format - Stick to // TODO: Description for best results
5. Review created issues - After running, check GitHub and refine issue descriptions
6. Don't run too frequently - Run when you want to create tracking issues, not after every code change
Example Workflow
# 1. Write TODOs in your code
# // TODO: Implement user profile caching
# // FIXME: Handle edge case when user has no email
# 2. Preview what issues would be created
./todo.sh --dry-run | less
# 3. Create the issues
./todo.sh
# 4. View created issues
gh issue list --label todo
# 5. Work on TODOs and close issues as you complete them
# (TODO comments should be removed from code when work is done)
# 6. Close issues when complete
gh issue close 42 --comment "Implemented in commit abc123"Support
For issues with the script:
1. Check this documentation
2. Run with --verbose flag for detailed output
3. Check prerequisite installation (gh CLI, git, authentication)
4. Review existing GitHub issues for similar problems
---
Created: April 28, 2026 Version: 1.0 Author: Generated by GitHub Copilot for theunpartyunppp project