{"id":35178489,"url":"https://github.com/sgtdi/vai","last_synced_at":"2026-01-13T22:58:09.735Z","repository":{"id":330020259,"uuid":"1104790331","full_name":"sgtdi/vai","owner":"sgtdi","description":"Hot reload Go apps, rebuild and restart Go projects on files change","archived":false,"fork":false,"pushed_at":"2026-01-05T15:43:33.000Z","size":2883,"stargazers_count":12,"open_issues_count":0,"forks_count":2,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-01-08T20:28:50.843Z","etag":null,"topics":["filewatcher","go","golang","hot-reload","live-reload","rebuild","rerun"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sgtdi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":["sgtdi","asoseil"],"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"lfx_crowdfunding":null,"polar":null,"buy_me_a_coffee":null,"thanks_dev":null,"custom":null}},"created_at":"2025-11-26T17:34:42.000Z","updated_at":"2026-01-05T15:43:37.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/sgtdi/vai","commit_stats":null,"previous_names":["sgtdi/watch","sgtdi/vai"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/sgtdi/vai","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sgtdi%2Fvai","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sgtdi%2Fvai/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sgtdi%2Fvai/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sgtdi%2Fvai/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sgtdi","download_url":"https://codeload.github.com/sgtdi/vai/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sgtdi%2Fvai/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28400943,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-13T14:36:09.778Z","status":"ssl_error","status_checked_at":"2026-01-13T14:35:19.697Z","response_time":56,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["filewatcher","go","golang","hot-reload","live-reload","rebuild","rerun"],"created_at":"2025-12-28T23:50:53.100Z","updated_at":"2026-01-13T22:58:09.727Z","avatar_url":"https://github.com/sgtdi.png","language":"Go","funding_links":["https://github.com/sponsors/sgtdi","https://github.com/sponsors/asoseil"],"categories":[],"sub_categories":[],"readme":"[![Go Reference](https://pkg.go.dev/badge/github.com/sgtdi/vai.svg)](https://pkg.go.dev/github.com/sgtdi/vai)\n[![Go Report Card](https://goreportcard.com/badge/github.com/sgtdi/vai)](https://goreportcard.com/report/github.com/sgtdi/vai)\n[![CI](https://github.com/sgtdi/vai/actions/workflows/ci-test.yml/badge.svg)](https://github.com/sgtdi/vai/actions/workflows/ci-test.yml)\n[![CodeQL](https://github.com/sgtdi/vai/actions/workflows/codeql.yml/badge.svg)](https://github.com/sgtdi/vai/actions/workflows/codeql.yml)\n[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)\n\n# Vai: Hot reload Go apps and projects\n\n\u003e *Vai (Italian: \"Go!\") - Because your code should go as fast as you do*\n\n**Stop the endless cycle of Ctrl+C → rebuild → restart** \n\nVai automatically rebuilds and restarts your Go applications the instant you save a file. Zero configuration, hassle and third-party dependencies.\n\n\u003cimg src=\"https://raw.githubusercontent.com/sgtdi/watch/refs/heads/dev/examples/vai-go-hot-reload.png\" width=\"100%\" alt=\"vai golang hot reload terminal interface\"\u003e\n\n## Index\n\n- [Get started](#-get-started-in-5-seconds)\n- [Why Vai?](#-why-vai)\n- [Use cases](#-use-cases)\n- [CLI reference](#-cli-reference)\n- [Advanced configuration](#-advanced-configuration-using-vaiyml)\n- [Real examples](#-real-examples)\n- [How it works](#-how-it-works)\n- [Tips and tricks](#-tips-and-tricks)\n- [Migrating](#-migrating-from-other-tools)\n- [Troubleshooting](#-troubleshooting)\n- [Contributing](#contributing)\n\n## ⚡ Get started in 5 seconds\n\n```bash\n# Install\ngo install github.com/sgtdi/vai@latest\n\n# Run\nvai go run .\n\n#Your app now hot reloads on every change\n```\n\nNo YAML files required, no configuration or external dependencies. **It just works**\n\n## 🎯 Why Vai?\n\n| Feature | Vai | Air | Fresh | Realize |\n|---------|:---:|:---:|:-----:|:-------:|\n| Works out of the box | ✅ | ✅  | ❌ | ❌ |\n| Zero config/flags needed | ✅ | ❌ | ❌ | ❌ |\n| No external dependencies | ✅ | ❌ | ❌ | ❌ |\n| CLI-first design | ✅ | ✅ | ✅ | ❌ |\n| Parallel job execution | ✅ | ❌ | ❌ | ✅ |\n| Built-in file watcher | ✅ | ❌ | ❌ | ❌ |\n| Setup time | 5 sec | 1 min | 3 min | 5 min |\n\n**Vai is the only hot reload tool for Go that:**\n- Requires **zero configuration** to get started\n- Has **zero external dependencies** (self-contained with built-in [fswatcher](https://github.com/sgtdi/fswatcher))\n- Works **instantly** - from install to hot reload in 5 seconds\n- Supports **complex workflows** with parallel and sequential job execution (when you need it)\n\n## 🔥 Use Cases\n\n### Web development (Gin, Echo, Chi, Fiber)\n\n```bash\nvai go run .\n```\n\nYour web server restarts instantly every time you save, perfect for api development.\n\n### Test-driven development\n\n```bash\nvai go test -v ./...\n```\n\nTests run automatically on every change. See results immediately.\n\n### Environment variables\n\n```bash\nvai --env=\"PORT=8080,DB_HOST=localhost,DB_USER=admin\" go run .\n```\n\nInject environment variables without shell scripts.\n\n### Watch specific files\n\n```bash\n# Only watch .go and .html files\nvai --regex=\".*\\\\.go$,.*\\\\.html$\" go run ./cmd/server\n\n# Ignore test files\nvai --regex=\".*\\\\.go$,!.*_test.go$\" go run .\n```\n\nFine-grained control over what triggers rebuilds.\n\n### Multiple commands (Chaining)\n\n```bash\n# Format then run\nvai --cmd \"go fmt ./...\" --cmd \"go run .\"\n\n# Lint, test, then run\nvai --cmd \"golangci-lint run\" --cmd \"go test ./...\" --cmd \"go run .\"\n```\n\nChain commands together and run in sequence.\n\n### Save and customize your configuration\n\n```bash\n# Save commands to vai.yml\nvai --path=./app --regex=\".*\\\\.go$\" --env=\"PORT=8080\" --save go run .\n\n# Then just run\nvai\n```\n\n## 📖 CLI reference\n\n```\nvai [flags] [command]\n\nUSAGE:\n  vai go run .                    # Simple hot reload\n  vai --cmd \"cmd1\" --cmd \"cmd2\"   # Multiple commands\n  vai                             # Use vai.yml config\n\nFLAGS:\n  -c, --cmd string      Command to run (can be used multiple times for sequential execution)\n  -p, --path string     Path to watch for changes (default: \".\")\n  -r, --regex string    Comma-separated regex patterns for files to watch (default: \".*\\\\.go$,^go\\\\.mod$,^go\\\\.sum$\")\n  -e, --env string      Comma-separated KEY=VALUE pairs for environment variables\n  -s, --save string     Save current CLI flags to a YAML configuration file\n  -d, --debug           Enable debug mode with detailed output and create a debug.log to record watcher events\n  -h, --help            Show this help message\n\nEXAMPLES:\n  # Basic hot reload\n  vai go run .\n  \n  # Watch specific directory\n  vai --path=./cmd/api go run ./cmd/api\n  \n  # Custom file patterns\n  vai --regex=\".*\\\\.go$,.*\\\\.html$,.*\\\\.css$\" go run .\n  \n  # With environment variables\n  vai --env=\"DEBUG=true,PORT=3000\" go run .\n  \n  # Chain multiple commands\n  vai --cmd \"go generate ./...\" --cmd \"go run .\"\n  \n  # Save configuration to vai.yml\n  vai --path=./app --env=\"ENV=dev\" --save go run ./app\n```\n\n## 🔧 Advanced configuration using `vai.yml`\n\nFor complex projects with multiple workflows, you can create a `vai.yml` file, that will be automatically detect and used.\n\n### Simple config\n\n```yaml\nconfig:\n  clearCli: true  # Clear screen before each reload\n\njobs:\n  # Main application\n  run-app:\n    trigger:\n      regex:\n        - \".*\\\\.go$\"\n        - \"!.*_test.go$\"  # Exclude test files\n    series:\n      - cmd: \"go fmt ./...\"\n      - cmd: \"go run .\"\n\n  # Run tests when test files change\n  test:\n    trigger:\n      paths:\n        - . # Entrypoint to watch for changes, multiple paths can be specified\n      regex:\n        - \".*_test\\\\.go$\"\n    series:\n      - cmd: \"go test -v ./...\"\n```\n\n### Parallel jobs\n\n```yaml\nconfig:\n  severity: info # Set logging level: debug, info, warn, error (default: warn)\n  clearCli: true\n  cooldown: 200ms\n\njobs:\n  # Development server\n  dev-server:\n    trigger:\n      regex:\n        - \".*\\\\.go$\"\n        - \"!.*_test.go$\"\n        - \".*\\\\.html$\"\n        - \".*\\\\.css$\"\n    series:\n      - cmd: \"go fmt ./...\"\n      - cmd: \"go run ./cmd/server\"\n    env:\n      - \"ENV=development\"\n      - \"PORT=8080\"\n\n  # Quality checks (runs in parallel)\n  quality:\n    trigger:\n      regex:\n        - \".*_test\\\\.go$\"\n    parallel:  # All commands run simultaneously\n      - cmd: \"go test -v -race ./...\"\n      - cmd: \"go vet ./...\"\n      - cmd: \"golangci-lint run --fast\"\n      - cmd: \"staticcheck ./...\"\n\n  # Assets pipeline\n  assets:\n    trigger:\n      regex:\n        - \".*\\\\.scss$\"\n        - \".*\\\\.js$\"\n    series:\n      - cmd: \"npm run build:css\"\n      - cmd: \"npm run build:js\"\n```\n\n### CLI and watcher customization\n\n```yaml\nconfig:\n  severity: warn             # Logging level: debug, info, warn, error (default: warn)\n  clearCli: false            # Clear terminal before running jobs (default: false)\n  cooldown: 100ms            # Wait time after file change to prevent duplicate triggers\n  batchingDuration: 1s       # Group multiple rapid changes into single trigger\n  bufferSize: 4096           # Event buffer size for high-velocity changes\n```\n\n## 📚 Real examples\n\nComplete working examples are in the [`examples/`](examples/) directory:\n\n| Example | Description | Use Case |\n|---------|-------------|----------|\n| [**simple-test**](examples/simple-test) | Auto-run tests on file changes | TDD workflow |\n| [**build-and-run**](examples/build-and-run) | Build binary then execute | Production-like workflow |\n| [**web-server**](examples/web-server) | Hot reload web application | Web development |\n| [**advanced-workflow**](examples/advanced-workflow) | Parallel jobs \u0026 complex pipelines | Enterprise projects |\n\nEach example includes:\n- Complete `vai.yml` configuration\n- Sample Go application\n- Detailed README with instructions\n\n## 🎓 How it works\n\nVai uses a custom-built file watcher called [fswatcher](https://github.com/sgtdi/fswatcher) that monitors your project for changes. When a file matching your patterns is modified:\n\n1. **Event Detection**: fswatcher detects the file change\n2. **Debouncing**: Vai waits for the cooldown period (default 100ms) to batch rapid changes\n3. **Job Matching**: Finds all jobs with regex patterns matching the changed file\n4. **Execution**: Runs matched jobs (series = sequential, parallel = simultaneous)\n5. **Process Management**: Cleanly stops the old process and starts the new one\n\nThis architecture means:\n- ⚡ **Fast**: No external process spawning overhead\n- 🎯 **Reliable**: Purpose-built file watcher with proven stability\n- 🔒 **Safe**: Proper process cleanup prevents zombie processes\n- 📦 **Simple**: Everything in one binary\n\n## 💡 Tips and tricks\n\n### Prevent duplicate rebuilds\n\n```yaml\nconfig:\n  cooldown: 200ms           # Wait 200ms after last change\n  batchingDuration: 500ms   # Group changes within 500ms window\n```\n\nUseful when your editor saves multiple files simultaneously.\n\n### Watch specific directories\n\n```bash\nvai --path=./internal go run ./cmd/api\n```\n\nIgnore changes outside your main source directory.\n\n### Debugging file watcher and general issues\n\n```bash\nvai --debug go run .\n```\n\nShows exactly which files are being watched and which events trigger rebuilds. \n\n### Exclude Generated Files\n\n```yaml\njobs:\n  app:\n    trigger:\n      regex:\n        - \".*\\\\.go$\"\n        - \"!.*\\\\.pb\\\\.go$\"      # Exclude protobuf generated files\n        - \"!.*_gen\\\\.go$\"       # Exclude go:generate output\n        - \"!vendor/.*\"          # Exclude vendor directory\n```\n\n### Multiple envs\n\n```bash\n# Development\nvai --env=\"ENV=dev,DB_HOST=localhost\" go run .\n\n# Staging (save to vai.staging.yml)\nvai --env=\"ENV=staging,DB_HOST=staging.db\" --save=vai.staging.yml go run .\n\n# Use staging config\nvai -f vai.staging.yml\n```\n\n## 🔄 Migrating from other tools\n\n### From Air\n\n**Air** requires `air.toml`:\n```toml\n[build]\n  cmd = \"go build -o ./tmp/main .\"\n  bin = \"./tmp/main\"\n  include_ext = [\"go\", \"html\"]\n```\n\n**Vai** needs nothing:\n```bash\nvai go run .\n```\n\nOr with equivalent config:\n```yaml\njobs:\n  app:\n    trigger:\n      regex: [\".*\\\\.go$\", \".*\\\\.html$\"]\n    series:\n      - cmd: \"go run .\"\n```\n\n### From Fresh\n\n**Fresh** requires `runner.conf`:\n```\nroot:              .\ntmp_path:          ./tmp\nbuild_name:        runner-build\nbuild_log:         runner-build-errors.log\n```\n\n**Vai** needs nothing:\n```bash\nvai go run .\n```\n\n## 🐛 Troubleshooting\n\n### Vai doesn't detect file changes\n\nCheck your regex patterns:\n   ```bash\n   vai --debug go run .  # Shows which files are watched\n   ```\n\nIncrease buffer size for large projects:\n   ```yaml\n   config:\n     bufferSize: 8192\n   ```\n\nSome editors save via rename/delete, just adjust cooldown:\n   ```yaml\n   config:\n     cooldown: 300ms\n   ```\n\n### Process doesn't stop cleanly\n\nVai sends SIGTERM (Unix) or taskkill (Windows) to processes. If your app doesn't handle shutdown gracefully:\n\n```go\n// Add signal handling to your main.go\nfunc main() {\n    ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM)\n    defer stop()\n    \n    // Your application code\n    \n    \u003c-ctx.Done()\n    // Cleanup\n}\n```\n\n### High CPU usage\n\nReduce file system events:\n\n```yaml\nconfig:\n  cooldown: 500ms           # Higher cooldown\n  batchingDuration: 1s      # Batch events\njobs:\n  app:\n    trigger:\n      regex:\n        - \"internal/.*\\\\.go$\"  # Watch only specific dirs\n        - \"!vendor/.*\"         # Exclude vendor\n        - \"!node_modules/.*\"   # Exclude node_modules\n```\n\n## Contributing\n\nContributions are welcome! Help making Vai better.\n\n- 🐛 **Report bugs** - [Open an issue](https://github.com/sgtdi/vai/issues/new)\n- 💡 **Suggest features** - [Start a discussion](https://github.com/sgtdi/vai/discussions/new)\n- 📖 **Improve docs** - Submit a PR with documentation fixes\n- 🔧 **Submit PRs** - Check [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines\n- ⭐ **Star the repo** - Helps others discover Vai\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsgtdi%2Fvai","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsgtdi%2Fvai","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsgtdi%2Fvai/lists"}