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: 19 languages including Go, JavaScript, TypeScript, PHP, 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 git hook installation; pre-commit hook works with GitHub Desktop
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 hook. This automatically prevents you from committing or pushing code with BARK comments:
# Install bark
go install github.com/debkanchan/bark/cmd/bark@latest
# Install the hook (default: pre-commit)
bark git-hook install
# Or install the pre-push hook instead
bark git-hook install pre-pushThat's it! Bark runs automatically and blocks the operation if BARK comments are found.
- pre-commit (default): catches issues at commit time, works with all Git clients
- pre-push: catches issues at push time, allows local commits with BARK comments for WIP
Note: GitHub Desktop does not trigger pre-push hooks. Use the default pre-commit hook if you use GitHub Desktop.
You can install both hooks for double protection!
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 one or more paths:
bark ./src
bark ./src ./lib ./testsUsing flag syntax (single path only):
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 git-hook install [pre-commit|pre-push] # default: pre-commit
bark git-hook uninstall [pre-commit|pre-push] # default: pre-commitEach install will:
- β
Create or update the hook file in
.git/hooks/ - β Safely merge with existing hooks using markers
- β Back up any existing hook before modification
Bark uses markers (# BEGIN bark hook / # END bark hook) to identify its section, so it coexists safely with other hooks. Both hooks can be installed simultaneously for double protection!
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(s) to scan β space-separated for multiple | . |
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 |
| PHP | .php, .phtml, .php3, .php4, .php5 |
| 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 |
See CONTRIBUTING.md.
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