CLI tool for detecting broken links and localhost URLs in project files
Project description
๐ก๏ธ LinkGuard
Fast, async link validation for developers. Catch broken links before your users do.
LinkGuard is a fast, async Python CLI tool that scans your project files for broken links and development URLs. Catch 404s before your users do, and ensure localhost references don't leak into production.
โจ Features
- ๐ Blazing Fast - Async validation checks hundreds of links in seconds
- ๐ฏ Environment-Aware - Detect localhost/dev URLs that shouldn't reach production
- ๐จ Beautiful CLI - Rich progress bars and color-coded results
- ๐ Multiple Exports - JSON, CSV, and Markdown reports for automation
- ๐ Smart Extraction - Supports Markdown, HTML, JSON, JS/TS, and plain text
- โ๏ธ Zero Config - Works out of the box with sensible defaults
- ๐ ๏ธ Configurable -
.linkguardignoreandlinkguard.config.jsonsupport - โ Production Ready - 91 tests, 71% coverage, comprehensive documentation
๐ฆ Installation
# Install from PyPI (coming soon)
pip install linkguard
# Or install from source
git clone https://github.com/anubhabx/link-guard.git
cd link-guard
# Create virtual environment
python -m venv venv
# Activate virtual environment
# Windows (PowerShell)
.\venv\Scripts\Activate.ps1
# Linux/Mac
source venv/bin/activate
# Install in development mode (includes all dependencies)
pip install -e ".[dev]"
๐ก Tip: After installation with
pip install -e ".[dev]", you can uselinkguarddirectly instead ofpython -m linkguard.cli
๐ Quick Start
# Scan current directory
linkguard
# Scan specific directory
linkguard ./docs
# Production mode (flags localhost URLs as errors)
linkguard --mode prod
# Export results to JSON
linkguard --export report.json
# Custom timeout
linkguard --timeout 15
Example Output:
๐ Scanning directory: ./docs
Mode: dev | Timeout: 10s
โ Found 42 files to scan
โ Extracted 156 URLs
๐ Checking links...
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ 100% 156/156
โญโ Scan Summary โโโโโโโโโโโโโโฎ
โ Files scanned 42 โ
โ URLs found 156 โ
โ Working links 152 โ
โ Broken links 4 โ
โ Rule violations 0 โ
โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
๐ Documentation
| Document | Description |
|---|---|
| QUICKSTART.md | Installation, basic usage, and common examples |
| FEATURES.md | Complete feature list and capabilities |
| CONTRIBUTING.md | Development setup, testing, and contribution guidelines |
| RELEASE_NOTES.md | v1.0 release details and highlights |
| CHANGELOG.md | Full version history and changes |
โ๏ธ Configuration
Command-Line Options
linkguard [DIRECTORY] [OPTIONS]
Options:
--mode, -m dev|prod Scanning mode (default: dev)
--timeout, -t INTEGER Request timeout in seconds (default: 10)
--export, -e PATH Export to JSON/CSV/Markdown
--concurrency, -c INTEGER Max concurrent requests (default: 50)
--ignore, -i TEXT Comma-separated ignore patterns
--verbose, -v Detailed output
--help Show help
Configuration File
Create linkguard.config.json in your project root:
{
"mode": "prod",
"timeout": 15,
"concurrency": 100,
"ignore_patterns": ["node_modules/**", "*.min.js"],
"exclude_urls": ["https://example.local"],
"strict_ssl": false
}
See linkguard.config.json.example for all options.
Ignore File
Create .linkguardignore (gitignore-style syntax):
# Ignore directories
node_modules/
dist/**
build/
# Ignore file patterns
*.draft.md
temp-*.json
# Ignore domains
*.internal.company.com
example.local
๐๏ธ Supported File Types
| Type | Extensions | What's Extracted |
|---|---|---|
| Markdown | .md, .markdown |
[text](url) and bare URLs |
| HTML | .html, .htm |
href, src attributes |
| JSON | .json |
URL strings in values |
| JavaScript/TypeScript | .js, .jsx, .ts, .tsx |
Bare URL patterns |
| Plain Text | .txt |
HTTP/HTTPS URLs |
Auto-excluded: .git, .venv, node_modules, __pycache__, dist, build
๐ง CI/CD Integration
GitHub Actions
name: Link Validation
on: [push, pull_request]
jobs:
check-links:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install LinkGuard
run: pip install linkguard
- name: Check links
run: linkguard --mode prod --export report.json
- name: Upload report
if: failure()
uses: actions/upload-artifact@v3
with:
name: link-report
path: report.json
Exit Codes:
0- All links valid1- Broken links or rule violations found2- Configuration error
๐ฏ Use Cases
โ
Documentation Sites - Ensure all links work before publishing
โ
Open Source Projects - Validate README and wiki links
โ
Marketing Sites - Check landing pages and blog posts
โ
CI/CD Pipelines - Automated link checking on every commit
โ
Pre-Production Checks - Catch localhost URLs before deployment
โ
Content Migration - Validate links after CMS migrations
๐ค Contributing
We welcome contributions! See CONTRIBUTING.md for:
- Development setup and workflow
- Testing guidelines (91 tests, 71% coverage)
- Code style requirements (PEP 8, Black, type hints)
- Pull request process
Quick Start:
git clone https://github.com/anubhabx/link-guard.git
cd link-guard
python -m venv venv
source venv/bin/activate # or .\venv\Scripts\Activate.ps1 on Windows
pip install -e ".[dev]"
pytest tests/ -v
๐บ๏ธ Roadmap
โ v1.0 (Current - October 2025)
- Production-ready release
- Comprehensive documentation
- 91 passing tests with 71% coverage
- GitHub Actions CI/CD
- Published to PyPI
๐ง v1.1.0 (Planned)
- Retry logic with exponential backoff
- Custom HTTP headers support
- Relative URL resolution
- Enhanced performance optimizations
๐ฎ v2.0.0 (Future)
- Anchor link validation (
#section) - Browser automation (Playwright) for bot detection bypass
- Web dashboard for analytics
- Webhook notifications (Slack/Discord)
See FEATURES.MD for complete roadmap.
๐ Performance
Benchmarks (typical projects):
- โ 100 links validated in ~2 seconds
- โ 1,000 links validated in ~5 seconds
- โ 10,000 files scanned in <30 seconds
Architecture:
- Async I/O with
aiohttpfor concurrent requests - Semaphore-based concurrency control (default: 50)
- Memory-efficient streaming file reads
- HEAD request with smart GET fallback
๐ Troubleshooting
Valid links marked as broken?
- Some servers block automated requests โ Increase timeout:
--timeout 20
"Connection timeout" errors?
- Network latency or slow servers โ Try:
--timeout 30
Ignore specific files/URLs?
- Use
.linkguardignoreor add tolinkguard.config.json
Command not found?
- Ensure installed:
pip install -e ".[dev]" - Or use:
python -m linkguard.cli
SSL certificate errors?
- LinkGuard skips SSL verification by default
- Coming soon:
--strict-sslflag
See QUICKSTART.MD for more troubleshooting tips.
๐ License
MIT License - see LICENSE file for details.
๐ Acknowledgments
Built with these amazing tools:
- aiohttp - Async HTTP client
- typer - Modern CLI framework
- rich - Beautiful terminal formatting
- beautifulsoup4 - HTML parsing
Special thanks to all contributors! ๐
๐ Support
- ๐ Bug Reports: GitHub Issues
- ๐ฌ Discussions: GitHub Discussions
- ๐ก Feature Requests: Open an Issue
- ๐ง Contact: anubhabxdev@gmail.com
Made with โค๏ธ for the open-source community
If you find LinkGuard useful, please give it a โญ!
Documentation โข Features โข Contributing โข Changelog
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file linkguard-1.0.1.tar.gz.
File metadata
- Download URL: linkguard-1.0.1.tar.gz
- Upload date:
- Size: 44.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
82eaa59eb62189f930234c2190b1e15866fd8b311db3fe605f6d28ef38143917
|
|
| MD5 |
680ea5c071e8748247aff5989d53fc4f
|
|
| BLAKE2b-256 |
e992cbf55185bbb855e18182ead6742aa3ea4662a72908fd5b5d7c1ed80d01dd
|
File details
Details for the file linkguard-1.0.1-py3-none-any.whl.
File metadata
- Download URL: linkguard-1.0.1-py3-none-any.whl
- Upload date:
- Size: 30.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7c9f3b8a93a1e9c85ce5ffde8960c3278eb877366dbb2fad30d561662384e476
|
|
| MD5 |
2a142c24408d756fb93a38ac6fbf0c4c
|
|
| BLAKE2b-256 |
e75df4094ec5f9e077d267a2c78c82ce4e5786cd47b16441a8ed39f0eb3448fb
|