This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
This repository is a comprehensive multi-language toolkit for ad-blocking, network protection, and AdGuard DNS management:
- TypeScript (
src/rules-compiler-typescript/) - Deno 2.0+ with npm compatibility - C#/.NET 10 (
src/rules-compiler-dotnet/) - Library and Spectre.Console CLI with DI support - Python 3.9+ (
src/rules-compiler-python/) - pip-installable package with CLI and API - Rust (
src/rules-compiler-rust/) - High-performance single binary with zero runtime deps
- Bash (
src/rules-compiler-shell/compile-rules.sh) - Linux/macOS - Zsh (
src/rules-compiler-shell/compile-rules.zsh) - macOS/Linux with zsh-specific features - PowerShell Core (
src/rules-compiler-shell/compile-rules.ps1) - Cross-platform - Windows Batch (
src/rules-compiler-shell/compile-rules.cmd) - Windows wrapper
- RulesCompiler Module (
src/adguard-api-powershell/) - Full-featured PowerShell API with Pester tests
- AdGuard API Client - .NET (
src/adguard-api-dotnet/) - C# SDK for AdGuard DNS API v1.11 - AdGuard API Client - TypeScript (
src/adguard-api-typescript/) - TypeScript SDK with Deno support - Console UI (
src/adguard-api-dotnet/src/AdGuard.ConsoleUI/) - Spectre.Console interactive interface - Linear Import Tool (
src/linear/) - TypeScript tool with Deno support
All compilers support JSON, YAML, and TOML configuration formats with full @jk-com/adblock-compiler compatibility.
A fully-featured Docker environment with all compilers and tools:
# Dockerfile.warp
FROM mcr.microsoft.com/dotnet/sdk:10.0-noble
# Includes: .NET 10 SDK, Deno 2.x, Python 3.12, Rust stable, PowerShell 7
# Pre-installed: hostlist-compiler (via Deno), yq, pytest, ruff, clippy, PesterBuild and run:
docker build -f Dockerfile.warp -t ad-blocking-dev .
docker run -it -v $(pwd):/workspace ad-blocking-devDocker Compose (recommended):
docker compose up -d dev # Start dev environment
docker compose exec dev bash # Enter container
docker compose --profile test run --rm test # Run all testsWarp Environment: jaysonknight/warp-env:ad-blocking (ID: Egji4sZU4TNIOwNasFU73A)
cd src/rules-compiler-typescript
# Deno tasks
deno task start # Start (auto-detect interactive or CLI mode)
deno task interactive # Interactive menu mode
deno task compile # CLI compile mode
deno task compile:yaml # Compile using YAML config
deno task compile:toml # Compile using TOML config
deno task dev # Run with watch mode
deno task test # Run Deno tests
deno task test:coverage # Run tests with coverage
deno task lint # Lint source files
deno task fmt # Format source files
deno task check # Type check
deno task version # Show version
# CLI with options
deno task start -- -c config.yaml -r -d # CLI mode with config
deno task start -- --interactive # Force interactive mode
deno task start -- --validate -c config.yaml # Validate only
deno run --allow-read --allow-write --allow-env --allow-run src/mod.ts --help
deno run --allow-read --allow-write --allow-env --allow-run src/mod.ts --version# Bash (Linux/macOS)
./src/rules-compiler-shell/compile-rules.sh # Use default config
./src/rules-compiler-shell/compile-rules.sh -c config.yaml -r # YAML config, copy to rules
./src/rules-compiler-shell/compile-rules.sh -v # Show version
# Zsh (macOS/Linux)
./src/rules-compiler-shell/compile-rules.zsh # Use default config
./src/rules-compiler-shell/compile-rules.zsh -c config.yaml -r # YAML config, copy to rules
./src/rules-compiler-shell/compile-rules.zsh -v # Show version
# PowerShell Core (all platforms)
./src/rules-compiler-shell/compile-rules.ps1
./src/rules-compiler-shell/compile-rules.ps1 -ConfigPath config.yaml -CopyToRules
./src/rules-compiler-shell/compile-rules.ps1 -Version
# Windows Batch
src\rules-compiler-shell\compile-rules.cmd -c config.json -rcd src/rules-compiler-dotnet
dotnet restore RulesCompiler.slnx
dotnet build RulesCompiler.slnx
dotnet test RulesCompiler.slnx
dotnet run --project src/RulesCompiler.Console/RulesCompiler.Console.csproj
# Command-line options
dotnet run --project src/RulesCompiler.Console -- --config path/to/config.yaml
dotnet run --project src/RulesCompiler.Console -- --config config.json --copy
dotnet run --project src/RulesCompiler.Console -- --config config.yaml --verbose
dotnet run --project src/RulesCompiler.Console -- --config config.yaml --validate
dotnet run --project src/RulesCompiler.Console -- --versioncd src/rules-compiler-python
# Install in development mode
pip install -e .
# Install with dev dependencies
pip install -e ".[dev]"
# Run tests
pytest
pytest -v # Verbose output
pytest --cov=rules_compiler # With coverage
# CLI usage
rules-compiler # Use default config
rules-compiler -c config.yaml # Specific config
rules-compiler -c config.json -r # Compile and copy to rules
rules-compiler -c config.toml -o out.txt # Custom output
rules-compiler -V # Show version info
rules-compiler -d # Debug output
rules-compiler --help # Show helpcd src/rules-compiler-rust
# Build
cargo build # Debug build
cargo build --release # Release build (optimized)
# Run tests
cargo test
cargo test -- --nocapture # With output
# CLI usage
cargo run -- -c config.yaml # Specific config
cargo run -- -c config.json -r # Compile and copy to rules
cargo run -- -c config.toml -o out.txt # Custom output
cargo run -- -V # Show version info
cargo run -- -d # Debug output
cargo run -- --help # Show help
# Release binary
./target/release/rules-compiler -c config.yamlcd src/adguard-api-dotnet
dotnet restore src/AdGuard.ApiClient.sln
dotnet build src/AdGuard.ApiClient.sln
dotnet test src/AdGuard.ApiClient.sln
dotnet run --project src/AdGuard.ConsoleUI/AdGuard.ConsoleUI.csproj
# Run benchmarks
dotnet run --project src/AdGuard.ApiClient.Benchmarks -c Releasecd src/adguard-api-typescript
# Deno tasks
deno task start # Start CLI
deno task sync # Sync rules
deno task cli # Run CLI directly
deno task test # Run tests
deno task test:coverage # Run tests with coverage
deno task lint # Lint source files
deno task fmt # Format source files
deno task check # Type checkcd src/linear
# Deno tasks
deno task import # Run import tool
deno task import:docs # Import documentation
deno task import:dry-run # Preview import
deno task cli # Run CLI directly
deno task test # Run tests
deno task lint # Lint source files
deno task fmt # Format source files
deno task check # Type check# Import the module
Import-Module ./src/adguard-api-powershell/Invoke-RulesCompiler.psm1
# Check versions and platform info
Get-CompilerVersion | Format-List
# Compile filter rules
Invoke-RulesCompiler
# Compile and copy to rules directory
Invoke-RulesCompiler -CopyToRules
# Run interactive harness
./src/adguard-api-powershell/RulesCompiler-Harness.ps1
# Run Pester tests
Invoke-Pester -Path ./src/adguard-api-powershell/Tests/RulesCompiler-Tests.ps1
# Lint with PSScriptAnalyzer
Invoke-ScriptAnalyzer -Path src/adguard-api-powershell -Recursecd src/rules-compiler-typescript
deno test src/cli.test.ts # By file
deno test --filter "parseArgs" # By test name
deno task test:coverage # With coveragecd src/adguard-api-dotnet
dotnet test src/AdGuard.ApiClient.sln --filter "FullyQualifiedName~DevicesApiTests" # By class
dotnet test src/AdGuard.ApiClient.sln --filter "Name~GetAccountLimits" # By method
cd ../rules-compiler-dotnet
dotnet test RulesCompiler.slnx --filter "FullyQualifiedName~ConfigurationValidatorTests"
dotnet test RulesCompiler.slnx --filter "FullyQualifiedName~TransformationTests"# Run all PowerShell tests
Invoke-Pester -Path ./src/adguard-api-powershell/Tests/
# Run specific test file
Invoke-Pester -Path ./src/adguard-api-powershell/Tests/RulesCompiler-Tests.ps1
# Run with detailed output
Invoke-Pester -Path ./src/adguard-api-powershell/Tests/ -Output Detailedcd src/rules-compiler-python
pytest # Run all tests
pytest -v # Verbose output
pytest tests/test_config.py # Specific file
pytest -k "test_read_yaml" # By test name
pytest --cov=rules_compiler # With coveragecd src/rules-compiler-rust
cargo test # Run all tests
cargo test -- --nocapture # With output
cargo test test_count_rules # Specific test
cargo test config:: # Tests in moduledata/output/adguard_user_filter.txt- Main tracked filter list consumed by AdGuard DNS
- TypeScript compiler using @jk-com/adblock-compiler
- Deno 2.0+ runtime with npm compatibility
- Supports JSON, YAML, and TOML configuration formats
- Library API (
src/lib/):RulesCompiler- Main service class with fluent builder patternConfigurationBuilder- Programmatic configuration creation- Separate library export:
@rules-compiler/typescript/lib
- Dual Mode Support:
- Interactive menu mode (default when no args)
- CLI mode (when config path or action flags provided)
src/cli.ts- Command-line interface with argument parsing and mode detectionsrc/config-reader.ts- Multi-format configuration readersrc/compiler.ts- Core compilation logicsrc/console/- Interactive console UI components:app.ts-ConsoleApplicationclass with menu-driven interfaceutils.ts- Console utilities (spinners, tables, colored output)
src/mod.ts- Deno entry pointdeno.json- Deno configuration and tasks- Key classes:
RulesCompiler,RulesCompilerBuilder,ConfigurationBuilder,ConsoleApplication - Uses Deno's built-in testing framework
- Cross-platform shell scripts for filter compilation
compile-rules.sh- Bash script for Linux/macOScompile-rules.zsh- Zsh script with native zsh features (zparseopts, EPOCHREALTIME)compile-rules.ps1- PowerShell Core script (all platforms)compile-rules.cmd- Windows batch wrapper- Supports JSON, YAML, TOML via external tools (yq, Python)
- .NET 10 library for filter compilation
- Supports JSON, YAML, and TOML configuration formats
RulesCompiler- Core library with abstractions, models, and servicesRulesCompiler.Console- Spectre.Console interactive and CLI frontendRulesCompiler.Tests- xUnit tests- Key interfaces:
IRulesCompilerService,IConfigurationReader,IFilterCompiler - Features: Configuration validation, verbose mode, dependency injection
- Python 3.9+ package for filter compilation
- Supports JSON, YAML, and TOML configuration formats
rules_compiler/config.py- Multi-format configuration readerrules_compiler/compiler.py- CoreRulesCompilerclass andcompile_rules()functionrules_compiler/cli.py- argparse-based CLI- Install via
pip install -e .for development - Key classes:
RulesCompiler,CompilerConfiguration,CompilerResult - Tools: pytest, mypy, ruff
- High-performance Rust library and CLI for filter compilation
- Supports JSON, YAML, and TOML configuration formats
src/config.rs- Configuration structs and parsingsrc/compiler.rs-RulesCompilerstruct andcompile_rules()functionsrc/main.rs- clap-based CLI with argument parsingsrc/error.rs-CompilerErrorenum with thiserror- Single binary distribution with zero runtime dependencies (except hostlist-compiler)
- Key structs:
RulesCompiler,CompilerConfiguration,CompilerResult,VersionInfo - LTO optimization enabled for small binary size
- Auto-generated from
api/openapi.json(primary) andapi/openapi.yaml(optional) - AdGuard DNS API v1.11 Helpers/ConfigurationHelper.cs- Fluent auth, timeouts, user agentHelpers/RetryPolicyHelper.cs- Polly-based retry for 408/429/5xx- Uses Newtonsoft.Json and JsonSubTypes
- Benchmarks project for performance testing
- TypeScript SDK for AdGuard DNS API v1.11 with feature parity to .NET version
- Deno 2.0+ runtime with npm compatibility
- Library API (
src/lib/):AdGuardDnsClientBuilder- Fluent builder for client configurationPagedListBuilder- Pagination support for list operations- Separate library export:
@adguard/api-typescript/lib
src/client.ts- MainAdGuardDnsClientclass with fluent APIsrc/api/- API endpoint implementations (account, devices, DNS servers, statistics, etc.)src/repositories/- Higher-level repository pattern abstractionssrc/cli/- Interactive CLI with menu-driven interfacesrc/mod.ts- Deno entry point- Key classes:
AdGuardDnsClient,AdGuardDnsClientBuilder,DeviceRepository,DnsServerRepository - Dependencies (via npm:): axios, commander, inquirer, chalk
- TypeScript tool for importing documentation into Linear project management
- Deno 2.0+ runtime with npm compatibility
src/linear-import.ts- Main CLI entry pointsrc/mod.ts- Deno entry pointsrc/parser.ts- Markdown documentation parsersrc/linear-client.ts- Linear API client wrappersrc/types.ts- TypeScript type definitions- Dependencies (via npm:): @linear/sdk, commander, marked, dotenv
- Spectre.Console menu-driven interface
ApiClientFactoryconfigures SDK from settings or interactive prompt- Features: Device management, DNS servers, statistics, query logs, filter lists
- RulesCompiler Module - Cross-platform PowerShell API mirroring TypeScript compiler
Invoke-RulesCompiler.psm1- Main module with exported functionsRulesCompiler.psd1- Module manifestRulesCompiler-Harness.ps1- Interactive test harnessTests/- Pester test suite- Functions:
Read-CompilerConfiguration,Invoke-FilterCompiler,Write-CompiledOutput,Invoke-RulesCompiler,Get-CompilerVersion
All compilers support the same @jk-com/adblock-compiler configuration schema:
| Property | Type | Required | Description |
|---|---|---|---|
name |
string | Yes | Filter list name |
description |
string | No | Description |
homepage |
string | No | Homepage URL |
license |
string | No | License identifier |
version |
string | No | Version number |
sources |
array | Yes | List of filter sources |
transformations |
array | No | Global transformations |
inclusions |
array | No | Global include patterns |
exclusions |
array | No | Global exclude patterns |
| Property | Type | Required | Description |
|---|---|---|---|
source |
string | Yes | URL or file path |
name |
string | No | Source identifier |
type |
string | No | adblock or hosts |
transformations |
array | No | Source-specific transforms |
inclusions |
array | No | Source-specific includes |
exclusions |
array | No | Source-specific excludes |
RemoveComments, Compress, RemoveModifiers, Validate, ValidateAllowIp, Deduplicate, InvertAllow, RemoveEmptyLines, TrimLines, InsertFinalNewLine, ConvertToAscii
| Variable | Description |
|---|---|
ADGUARD_API_KEY |
Universal API credential (works with all languages - recommended) |
AdGuard:ApiKey |
.NET appsettings.json format |
ADGUARD_AdGuard__ApiKey |
.NET environment variable hierarchical format (legacy) |
ADGUARD_LINEAR_API_KEY |
Linear API key for Linear import scripts (src/linear/) |
ADGUARD_LINEAR_TEAM_ID |
Optional Linear team ID |
ADGUARD_LINEAR_PROJECT_NAME |
Optional Linear project name |
DEBUG |
Set to any value to enable debug logging |
LOG_LEVEL |
Log level (DEBUG, INFO, WARN, ERROR, SILENT) |
LOG_FORMAT |
Set to json for structured logging |
RULESCOMPILER_config |
Default configuration file path (.NET compiler) |
RULESCOMPILER_Logging__LogLevel__Default |
Log level for .NET compiler |
GitHub Actions workflows validate:
.github/workflows/dotnet.yml- Builds/tests .NET projects (API client and rules compiler) with .NET 10.github/workflows/typescript.yml- Deno 2.x for all TypeScript projects.github/workflows/security.yml- Consolidated security scanning (CodeQL, DevSkim, PSScriptAnalyzer).github/workflows/release.yml- Builds and publishes release binaries (.NET, Rust, Python).github/workflows/claude.yml- Claude AI integration for @claude mentions.github/workflows/claude-code-review.yml- Automated PR code review
| Requirement | Version | Required For |
|---|---|---|
| .NET SDK | 10.0+ | .NET compiler, API client |
| Deno | 2.0+ | TypeScript projects (rules compiler, API client, linear) |
| PowerShell | 7+ | PowerShell scripts |
| Python | 3.9+ | Python compiler |
| Rust | 1.85+ | Rust compiler (install via rustup) |
| adblock-compiler | 0.6.0 | TypeScript compiler (via JSR: deno add @jk-com/adblock-compiler) |
| Docker | 24.0+ | Container development (optional but recommended) |
- Main filter list:
data/output/adguard_user_filter.txt - Compiler configs:
src/rules-compiler-*/ - Deno configs:
src/*/deno.json - OpenAPI spec:
api/openapi.yaml - Docker config:
Dockerfile.warp,docker-compose.yml,.dockerignore - Documentation:
docs/ - Environment template:
.env.example