# Custom Type Definitions
## Rule
Define custom ripgrep types for project-specific file patterns that are not covered by built-in types. Add them to .ripgreprc for team-wide consistency.
## Format
```
# .ripgreprc
--type-add=web:*.tsx,*.jsx,*.css,*.html
--type-add=config:*.json,*.yaml,*.yml,*.toml
--type-add=infra:*.tf,*.hcl,*.pkr.hcl
--type-add=test:*test*,*spec*,*_test.go
```
## Good Examples
```bash
# Define custom types in .ripgreprc
--type-add=web:*.tsx,*.jsx,*.css,*.html
--type-add=config:*.json,*.yaml,*.yml,*.toml
--type-add=infra:*.tf,*.hcl
--type-add=ci:*.yml # in .github/
# Use custom types
rg -t web "className"
rg -t config "database"
rg -t infra "aws_instance"
# Combine multiple types
rg -t ts -t js "import"
# Exclude a type
rg -T test "function" # Skip test files
# List all known types
rg --type-list
# Add type on the fly
rg --type-add 'proto:*.proto' -t proto "message"
```
## Bad Examples
```bash
# BAD: Manual glob instead of type
rg "pattern" -g "*.tsx" -g "*.jsx" -g "*.css" -g "*.html"
# Define a custom type instead
# BAD: No type filter — searches everything
rg "TODO"
# Binary files, lock files, generated code all included
# Use: rg -t ts "TODO" or configure .rgignore
```
## Enforcement
- Document custom types in project .ripgreprc or contributing guide
- Use type filters consistently in scripts and documentation
- Share .ripgreprc in team dotfiles repository