Ever changed something temporarily to test something locally that should never be in production/in your PR but forgot to revert the change before pushing? Me too.
Bark is an "embarrassment linter" that detects BARK comments in your code. Add BARK comments to temporary code and Bark! will stop you from pushing it to version control.
- π Bark! - Save yourself from embarrassments
- π Cross-platform: Works on Windows, macOS, and Linux
- β‘ Fast: Concurrent file processing using goroutines
- π³ Tree-sitter powered: Accurate parsing using tree-sitter grammars
- π§ Modular architecture: Separated core logic for easy integration
- π Multiple output formats: Text for CLI, JSON for CI/CD pipelines
- π― Wide language support: 18 languages including Go, JavaScript, TypeScript, Python, Java, Kotlin, C, C++, Bash, Rust, Zig, Lua, HCL, YAML, Docker, XML, TOML, JSON
- π¬ GitHub Action: One-line integration for your CI/CD pipeline
- πͺ Git Hooks: Automatic pre-push hook installation
go install github.com/debkanchan/bark/cmd/bark@latestgit clone https://github.com/debkanchan/bark.git
cd bark
go build -o bark ./cmd/barkThe easiest way to use Bark is to install it as a git pre-push hook. This automatically prevents you from pushing code with BARK comments:
# Install bark
go install github.com/debkanchan/bark/cmd/bark@latest
# Install the git hook (one-time setup)
bark git-hook installThat's it! Now bark runs automatically before every git push and blocks the push if BARK comments are found.
Use BARK comments as reminders for things that need to be fixed before pushing:
package main
import "fmt"
// BARK: Remove debug code before commit
func main() {
fmt.Println("Debug mode enabled")
// BARK: Replace with proper configuration
apiKey := "test-key-123"
}When you try to push:
$ git push
π Running bark to check for BARK comments...
Found 2 BARK comment(s):
main.go:4:1: // BARK: Remove debug code before commit
main.go:7:5: // BARK: Replace with proper configuration
β Push blocked: BARK comments found
Please remove BARK comments before pushingFix the issues, and push successfully! β
If you need to manually scan your code without git hooks:
Scan current directory:
bark
# or explicitly
bark .Scan specific path:
bark ./src
bark ./path/to/codeUsing flag syntax (alternative):
bark -path ./src
bark -p ./srcText format (default) - Human-readable output:
bark ./src
bark -format text .JSON format - For CI/CD integration and parsing:
bark -format json .
bark -f json ./testdataJSON output example:
{
"findings": [
{
"file_path": "main.go",
"line": 4,
"column": 1,
"comment": "// BARK: Remove debug code"
}
],
"count": 1
}Bark can automatically install a git pre-push hook to prevent BARK comments from being pushed:
Install pre-push hook:
bark git-hook installThis will:
- β
Create or update
.git/hooks/pre-push - β Safely merge with existing hooks using markers
- β Back up any existing hook before modification
- β
Run bark automatically before each
git push - β Block pushes if BARK comments are found
Uninstall pre-push hook:
bark git-hook uninstallThis will:
- β Remove only the bark section (preserves other hooks)
- β Back up the hook before modification
- β Delete the file if empty after removal
How it works:
Bark uses markers (# BEGIN bark hook / # END bark hook) to identify its section, allowing it to coexist with other git hooks safely.
0- No BARK comments found (clean)1- BARK comments found2- Error occurred during scanning
Add Bark to your GitHub Actions workflow with a single line:
name: Check for BARK comments
on: [push, pull_request]
jobs:
bark:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: debkanchan/bark@v1Scan specific directory:
- uses: debkanchan/bark@v1
with:
path: './src'JSON output:
- uses: debkanchan/bark@v1
with:
format: 'json'Report only (don't fail the build):
- uses: debkanchan/bark@v1
with:
fail-on-findings: 'false'Specific version:
- uses: debkanchan/bark@v1
with:
version: 'v1.0.0'| Input | Description | Default | Required |
|---|---|---|---|
path |
Path to scan for BARK comments | . |
No |
format |
Output format (text or json) |
text |
No |
fail-on-findings |
Fail the build if BARK comments found | true |
No |
version |
Bark version to install (latest or v1.0.0) |
latest |
No |
Complete workflow with multiple jobs:
name: Code Quality
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main ]
jobs:
bark-check:
name: Check for BARK Comments
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: debkanchan/bark@v1
with:
path: '.'
format: 'text'Matrix strategy - scan multiple directories:
jobs:
bark-matrix:
runs-on: ubuntu-latest
strategy:
matrix:
directory: ['./frontend', './backend', './shared']
steps:
- uses: actions/checkout@v4
- uses: debkanchan/bark@v1
with:
path: ${{ matrix.directory }}Manual installation (if you need more control):
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "1.21"
- name: Install Bark
run: go install github.com/debkanchan/bark/cmd/bark@latest
- name: Run Bark
run: bark -format json .| Language | Extensions |
|---|---|
| Go | .go |
| JavaScript | .js, .jsx, .mjs, .cjs |
| TypeScript | .ts, .tsx |
| Python | .py, .pyw |
| Java | .java |
| Kotlin | .kt, .kts |
| C | .c, .h |
| C++ | .cpp, .cc, .cxx, .hpp, .hh, .hxx |
| Bash | .sh, .bash, .env, .env.* |
| Rust | .rs |
| Zig | .zig |
| Lua | .lua |
| HCL | .hcl, .tf, .tfvars |
| YAML | .yml, .yaml |
| Docker | dockerfile, Dockerfile, *.dockerfile, *.Dockerfile |
| XML | .xml |
| TOML | .toml |
| JSON | .json, .jsonc |
Bark follows standard Go project layout with a modular architecture:
bark/
βββ cmd/bark/ # CLI entry point with git hook commands
βββ internal/
β βββ parser/ # Tree-sitter integration
β β βββ registry.go # Language registry
β β βββ parser.go # Comment extraction
β β βββ languages/ # Individual language configs
β βββ scanner/ # Concurrent file scanner with worker pool
β βββ results/ # Result types and formatters (text, JSON)
βββ action.yml # GitHub Action definition (composite)
βββ .github/workflows/ # CI/CD workflows
- Language Registry: Extensible registry mapping file extensions to tree-sitter parsers
- Parser: Uses tree-sitter queries to extract comments from source files
- Scanner: Concurrent file processing with worker pool pattern
- Formatters: Interface-based output formatting (text, JSON)
- Git Hooks: Smart installation with marker-based merging
- GitHub Action: Composite action using preinstalled Go (no Docker!)
# Run all tests
go test ./...
# Run with coverage
go test -cover ./...
# Run specific package
go test ./internal/parser
go test ./internal/scanner
go test ./internal/results
# Using Makefile
make test
make test-coverage# Install the hook in your bark repository
bark git-hook install
# Create a test commit with BARK comments
echo "// BARK test" >> test.go
git add test.go
git commit -m "test"
# Try to push (should be blocked)
git push
# Uninstall when done testing
bark git-hook uninstall-
Install the tree-sitter parser binding:
go get github.com/tree-sitter/tree-sitter-{language}/bindings/go -
Create a new file
internal/parser/languages/{language}.go:package languages import ( sitter "github.com/tree-sitter/go-tree-sitter" tree_sitter "github.com/tree-sitter/tree-sitter-{language}/bindings/go" ) func YourLanguage() Language { return Language{ Name: "YourLanguage", Extensions: []string{".ext"}, Parser: sitter.NewLanguage(tree_sitter.Language()), Query: "((comment) @comment)", } }
-
Add to the registry in
internal/parser/registry.go:languageList := []languages.Language{ // ... existing languages languages.YourLanguage(), }
-
Test it:
go build -o bark ./cmd/bark ./bark path/to/file.ext
Using the Makefile:
make build # Build the binary
make test # Run all tests
make test-coverage # Run tests with coverage report
make run-testdata # Test on sample files
make install # Install globally
make clean # Clean build artifactsContributions are welcome! Please feel free to submit a Pull Request.
- Add support for more programming languages
- Improve error messages
- Add configuration file support
- Enhance test coverage
- Improve documentation
GNU Affero General Public License - see LICENSE file for details
Like a faithful dog that barks to alert you, Bark helps you catch those temporary comments and debug code before they make it into your repository! π
Made with β€οΈ to prevent embarrassments