A simple but powerful GitHub Action that automatically scans your codebase for //TODO comments and reports their count and locations whenever code is merged.
As codebases grow, it's common to leave //TODO comments to mark areas that need future attention. However, these markers can easily be forgotten. This action helps you keep track of your technical debt by:
- Counting all
//TODOcomments in your codebase - Listing their exact locations (file, line number, and content)
- Providing this information as both a workflow output and a downloadable report
- Commenting the results on merged PRs
- Create a
.github/workflowsdirectory in your repository (if it doesn't exist already) - Create a new file
.github/workflows/todo-finder.yml - Copy the action YAML into this file
- Commit and push to your repository
That's it! The action will now run automatically whenever code is merged to your main branch.
The action is triggered on:
- Direct pushes to the main/master branch
- When a pull request to main/master is merged
It will not run on PRs that are closed without merging.
The action provides:
- GitHub Actions Workflow Summary: The total number of TODOs appears in the workflow run summary.
- Downloadable Report: A Markdown file with detailed information about TODO locations.
- PR Comments: If triggered by a merged PR, the action will comment on that PR with the results.
Example report:
# TODO Finder Results
Generated on: Mon Apr 04 15:23:45 UTC 2025
## Total TODOs found: 7
## TODO Locations:
- **src/components/UserProfile.js:42** - `//TODO: Add input validation`
- **src/utils/api.js:87** - `//TODO: Implement error handling`
- **src/reducers/auth.js:123** - `//TODO: Refactor this logic`
- ...By default, the action scans the following file types:
*.js, *.jsx, *.ts, *.tsx, *.java, *.py, *.rb, *.php, *.c, *.cpp, *.h, *.hpp, *.cs, *.go, *.swift, *.kt
To modify this list, edit the --include pattern in the Find TODOs step.
By default, the action excludes the following directories:
node_modules, .git, build, dist, vendor
To modify this list, edit the --exclude-dir pattern in the Find TODOs step.
This action searches for both //TODO (without space) and // TODO (with space) comment formats.
If you want to include additional formats (like Python-style # TODO comments), you can modify the grep patterns by adding to the regex pattern:
grep -r --include="*.{js,jsx,ts,tsx,java,py,rb,php,c,cpp,h,hpp,cs,go,swift,kt}" -E "(//TODO|// TODO|# TODO)" --exclude-dir={node_modules,.git,build,dist,vendor} . | wc -l- Ensure the workflow file is in the correct location (
.github/workflows/todo-finder.yml) - Check that you're merging to the branch specified in the workflow (default:
mainormaster) - Verify that your repository has GitHub Actions enabled
- Check if your TODO format matches what the action is searching for (default:
//TODO) - Ensure your file type is included in the search patterns
- Verify that the directory containing your TODOs isn't in the excluded list
This project is available under the MIT License. Feel free to modify and adapt it to your needs.
Contributions are welcome! Please feel free to submit a Pull Request.
For any issues or suggestions, please open an issue in this repository.