Problem
Currently, opencode does not automatically format code when changes are made. This requires developers to manually run formatters after making edits, which can lead to inconsistent code style or forgotten formatting.
Proposed Solution
Add hooks that automatically format code whenever a file is changed/saved within opencode. This would:
- Integrate with existing formatters (prettier, black, clang-format, etc.)
- Run automatically on file save or after code generation
- Support configurable formatting rules per project
- Be opt-in or configurable to avoid interfering with existing workflows
Implementation Ideas
- File watcher hook - Listen for file save/change events and trigger the appropriate formatter
- Post-generation hook - Run formatter immediately after opencode generates or modifies code
- Configuration file - Allow users to specify formatters per language/file type
Benefits
- Consistent code style across all changes
- Reduced manual steps for developers
- Cleaner commit history without separate formatting commits
- Better developer experience
Related
This would complement existing linting and type-checking capabilities.
Problem
Currently, opencode does not automatically format code when changes are made. This requires developers to manually run formatters after making edits, which can lead to inconsistent code style or forgotten formatting.
Proposed Solution
Add hooks that automatically format code whenever a file is changed/saved within opencode. This would:
Implementation Ideas
Benefits
Related
This would complement existing linting and type-checking capabilities.