Skip to content

πŸ§™ Interactive Git commit wizard with smart metadata trailers. Compose better commit messages with TUI-guided co-authors, issue references, and conventional commits. Built with Go + Charm.

License

Notifications You must be signed in to change notification settings

Zayan-Mohamed/gitwiz

GitWizard πŸ§™

Go Version Release License Build Status Go Report Card Security

A secure, user-friendly CLI tool that replaces git commit with an interactive commit context wizard.

πŸ“Έ Screenshots

Click to see the GitWizard UI in action

Commit Subject Input

Commit Subject

Commit Body (Optional)

Commit Body

Co-Authors Selection

Co-Authors

Issue References

References

Fixes Issues

Fixes

Final Commit Preview

Preview

✨ Features

  • Interactive TUI - Beautiful terminal UI powered by Charm's Huh
  • Co-Author Detection - Automatically scrapes recent contributors from git history
  • Smart Issue Linking - Extracts issue references from branch names
  • Clipboard Integration - Suggests references from clipboard
  • Security First - Built with command injection prevention
  • Git Trailer Support - Generates properly formatted trailers for GitHub/GitLab

πŸ“¦ Installation

Using Go Install

go install github.com/Zayan-Mohamed/gitwiz@latest

Download Binary

Download the latest binary from releases:

# Linux
wget https://github.com/Zayan-Mohamed/gitwiz/releases/latest/download/gitwiz-linux-amd64.tar.gz
tar -xzf gitwiz-linux-amd64.tar.gz && chmod +x gitwiz-linux-amd64.tar.gz
sudo mv gitwiz-linux-amd64 /usr/local/bin/gitwiz
# macOS
wget https://github.com/Zayan-Mohamed/gitwiz/releases/latest/download/gitwiz-darwin-amd64.tar.gz
tar -xzf gitwiz-darwin-amd64.tar.gz && chmod +x gitwiz-darwin-amd64.tar.gz
sudo mv gitwiz-darwin-amd64 /usr/local/bin/gitwiz
# windows
wget https://github.com/Zayan-Mohamed/gitwiz/releases/latest/download/gitwiz-windows-amd64.zip
# Extract and move (requires Admin PowerShell)
Expand-Archive -Path gitwiz-windows-amd64.zip -DestinationPath .
Move-Item -Path gitwiz-windows-amd64.exe -Destination C:\Windows\System32\gitwiz.exe

Build from Source

git clone https://github.com/Zayan-Mohamed/gitwiz.git
cd gitwiz
go build -o gitwiz
sudo mv gitwiz /usr/local/bin/

Using Installation Script

./install.sh

Usage

Instead of running git commit, simply run:

gitwiz          # Run the commit wizard
gitwiz --help   # Show help and usage information
gitwiz --version # Show version

Getting Help

  • Quick Help: gitwiz --help or gitwiz -h
  • Keyboard Navigation: See KEYBOARD_GUIDE.md for detailed navigation instructions
  • Usage Examples: See USAGE.md for comprehensive examples

The wizard will guide you through:

  1. Subject Line - Brief, imperative description (validated for length)
  2. Body - Optional detailed explanation
  3. Co-Authors - Select from recent contributors
  4. References - Link to related issues/PRs
  5. Fixes - Automatically close issues

Example Output

feat: Add user authentication

Implement JWT-based authentication with refresh tokens.
Added middleware for route protection.

Co-authored-by: Jane Doe <jane@example.com>
Refs: #123
Fixes: #456

πŸ—οΈ Architecture

gitwiz/
β”œβ”€β”€ main.go                         # CLI entry point with flag parsing
β”œβ”€β”€ internal/
β”‚   β”œβ”€β”€ git/
β”‚   β”‚   β”œβ”€β”€ git.go                  # Secure git operations (exec wrappers)
β”‚   β”‚   └── git_test.go             # Unit tests
β”‚   β”œβ”€β”€ logic/
β”‚   β”‚   β”œβ”€β”€ trailers.go             # Commit message building & validation
β”‚   β”‚   └── trailers_test.go        # Unit tests
β”‚   └── tui/
β”‚       └── form.go                 # Interactive TUI forms
β”œβ”€β”€ scripts/
β”‚   └── release.sh                  # release script
└── docs/
    β”œβ”€β”€ USAGE.md                    # Detailed usage guide
    β”œβ”€β”€ KEYBOARD_GUIDE.md           # Keyboard navigation reference
    └── SECURITY.md                 # Security documentation

Security Features

Command Injection Prevention

  • Uses exec.Command() with separate arguments (NOT shell string concatenation)
  • Example: exec.Command("git", "commit", "-m", msg) [OK]
  • NOT: exec.Command("sh", "-c", "git commit -m '"+msg+"'") [X]

Argument Injection Prevention

  • User input passed as literal values, never as flags
  • Protected against malicious input like --amend or ; rm -rf /

Input Sanitization

  • Email validation with regex before display
  • Control character stripping to prevent terminal corruption
  • Timeout on all external commands (2 seconds)

Edge Cases Handled

Scenario Behavior
Not a Git Repo Exit with friendly error
Nothing Staged Offer to stage all changes
No Commit History Show empty co-author list
Merge in Progress Warn and allow continuation
GPG Signing Stdin attached for passphrase prompt

Configuration (Future)

Custom trailers can be defined in ~/.gitwiz.yaml:

custom_trailers:
  Reviewed-by: "Zayan-Mohamed <itsm.zayan@gmail.com>"
  Ticket: "PROJ-123"

Requirements

  • Go 1.21+
  • Git 2.0+
  • Terminal with UTF-8 support

Development

Run tests:

go test ./...

Build:

go build -o gitwiz

License

MIT License - See LICENSE file for details.

Code of Conduct

This project follows the Contributor Covenant Code of Conduct. By participating, you are expected to uphold this code.

Contributing

Contributions welcome! Please read our Contributing Guidelines before submitting PRs.

Key Requirements:

  1. No use of go-git (use os/exec only)
  2. All git commands use exec.Command() safely
  3. Input validation on all user data
  4. Tests for edge cases
  5. Follow Conventional Commits

Credits

Built with:

Support


Made with ❀️ by Zayan Mohamed

About

πŸ§™ Interactive Git commit wizard with smart metadata trailers. Compose better commit messages with TUI-guided co-authors, issue references, and conventional commits. Built with Go + Charm.

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Packages

No packages published