This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
gat is a cat command alternative written in Go that provides syntax highlighting, code formatting, and enhanced display capabilities for terminal output.
# Run all tests
go test ./...
# Run tests with coverage
go test -coverprofile=coverage.out ./...# Build the project
go build -o gat
# Build with version information
go build -ldflags "-X main.version=X.Y.Z" -o gat# Run linter (golangci-lint must be installed)
golangci-lint run --verbose ./...# Check GoReleaser configuration
goreleaser check
# Build release snapshot (for testing)
goreleaser release --snapshot --clean-
cmd/: CLI command definitions using Cobra framework
root.go: Main command logic and flag handlingflags.go: Command-line flag definitionsversion.go: Version command implementation
-
internal/gat/: Core gat functionality
- Main logic for file processing, syntax highlighting, and output formatting
-
internal/formatters/: Output format processors
- HTML minification, JSON formatting, SVG optimization
-
internal/lexers/: Lexer utilities
- Wrapper functions for Chroma's lexer registry
-
internal/prettier/: Code prettifiers
- Language-specific formatting (CSS, Go, HTML, JSON, XML, YAML)
-
internal/masker/: Sensitive information masking
- Masks API keys, tokens, and other secrets in output
-
internal/styles/: Theme definitions
- Custom syntax highlighting themes
-
scripts/: Build scripts
- Shell completion generation
-
docs/: Documentation assets
- Demo GIFs, images, theme previews
-
tapes/: VHS tape files for generating demo GIFs
-
assets/: Logo files
- Chroma: Syntax highlighting engine (200+ language support)
- Cobra: CLI framework for command parsing
- Glamour: Markdown rendering with terminal styling
- go-sixel: Image display in terminal via Sixel protocol
- Modular Architecture: Each formatter, lexer, and prettifier is isolated in its own package
- Internal Packages: Core functionality is kept in
internal/to prevent external imports - Resource Management: Proper cleanup of file handles and resources
- Smart Output Detection: Automatic color handling based on terminal/pipe detection
The project uses Release Please for automated releases:
- PRs are automatically created with changelog updates
- Merging a release PR triggers GoReleaser
- Binaries are built for multiple platforms and published to GitHub Releases
- Homebrew formula is automatically updated
- Unit tests focus on formatters, prettifiers, and core functionality
- Test files follow Go convention:
*_test.goalongside implementation - Use table-driven tests where appropriate
- Mock external dependencies when needed
When adding new API key patterns to internal/masker/:
- Place more specific patterns before general ones to avoid false matches
- Example:
sk-ant-must be beforesk-to prevent Anthropic keys from matching OpenAI pattern - Example: AWS Secret Access Key (
[a-zA-Z0-9+/]{40}) must be last due to its generic pattern
- AWS Access Key ID (permanent):
AKIA[0-9A-Z]{16} - AWS Access Key ID (temporary/SSO):
ASIA[0-9A-Z]{16} - GitHub Tokens:
gh[pousr]_[a-zA-Z0-9]{36,} - GitLab PAT:
glpat-[a-zA-Z0-9\-_]{20,} - Slack Tokens:
xox[baprs]-[0-9a-zA-Z\-]+ - Anthropic API Key:
sk-ant-[a-zA-Z0-9\-_]+ - OpenAI API Key:
sk-(?:proj-)?[a-zA-Z0-9_\-]{20,}(supports both legacy and project formats) - Supabase Secret Key:
sb_secret_[a-zA-Z0-9\-_]+ - JWT Tokens:
eyJ[a-zA-Z0-9_-]*\.eyJ[a-zA-Z0-9_-]*\.[a-zA-Z0-9_-]* - Private Key Headers:
-----BEGIN\s+(RSA|DSA|EC|OPENSSH|PGP)\s+PRIVATE\s+KEY----- - AWS Secret Access Key:
[a-zA-Z0-9+/]{40}(must be last due to generic pattern)
- Add regex pattern to
internal/masker/masker.go - Add test cases to
internal/masker/masker_test.gowith realistic examples - Run tests:
go test ./internal/masker/... - Update README.md supported patterns list
- Test cases should include special characters (
_,-) where applicable