
Research
/Security News
Critical Vulnerability in NestJS Devtools: Localhost RCE via Sandbox Escape
A flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).
A streamlined command-line tool designed for developers to easily share their codebase with Large Language Models (LLMs). contextr helps you monitor specific files and directories, intelligently handles ignore patterns, and lets you instantly export formatted code context to your clipboard - perfect for pasting into ChatGPT, Claude, or other AI chat interfaces.
Think of it as "git add" but for AI conversations - select the files you want your AI assistant to see, and export them in a Markdown format optimized for LLM comprehension.
!
~
expansion, and environment variablesThe easiest way to install (requires Python 3.12+):
pip install contextr
This makes both ctxr
(short alias) and contextr
commands available globally.
# Clone the repository
git clone https://github.com/your-username/contextr.git
cd contextr
# Install using uv (recommended for development)
uv sync --extra dev
# Or install with pip
pip install -e .
# Initialize contextr in your project
ctxr init
# Add files to watch (supports glob patterns)
ctxr watch "src/**/*.py" "docs/*.md" "*.yaml"
# Ignore test files and build artifacts
ctxr ignore "**/__pycache__/**" "**/node_modules/**" "*.pyc"
# Sync watched files and copy to clipboard
ctxr sync
# Paste into your favorite LLM and start coding!
watch <patterns>
- Add file patterns to monitor
ctxr watch "src/**/*.py" "tests/**/*.py" "*.md"
unwatch <patterns>
- Remove patterns from watch list
ctxr unwatch "tests/**"
watch-list
- Display all watched patterns
ctxr watch-list
list
- Show current file context as a tree
ctxr list
sync
- Refresh context from watched files and export to clipboard
ctxr sync
init
- Initialize contextr in current directory
ctxr init
ignore <pattern>
- Add pattern to ignore list
ctxr ignore "**/*.log" "build/**"
unignore <pattern>
- Remove pattern from ignore list
ctxr unignore "**/*.log"
ignore-list
- Show all ignored patterns
ctxr ignore-list
gitignore-sync
- Import patterns from .gitignore
ctxr gitignore-sync
contextr supports standard glob patterns and git-style ignore syntax:
# Watch all Python files
ctxr watch "**/*.py"
# Watch specific directories
ctxr watch "src/" "lib/" "tests/"
# Watch with multiple extensions
ctxr watch "**/*.{js,jsx,ts,tsx}"
# Ignore patterns with negation
ctxr ignore "**/*.test.py" # Ignore all test files
ctxr ignore "!important.test.py" # But include this specific test
Save and instantly switch between different context configurations:
# Save current context as a profile
ctxr profile save backend --description "Backend API development"
# Load a saved profile
ctxr profile load backend
# List all saved profiles
ctxr profile list
# Delete a profile
ctxr profile delete backend
contextr generates clean, LLM-friendly Markdown output:
# Project Context: your-project
Files selected: 5
## File Structure
src/ ├── main.py ├── utils/ │ ├── helpers.py │ └── config.py └── models/ └── user.py README.md
## File Contents
### src/main.py
```python
# Your code here with proper syntax highlighting
# More code with language detection
## How It Works
1. **Pattern Matching**: Uses glob patterns to match files, with full support for `**` recursive matching
2. **Ignore System**: Implements git-style ignore rules including directory-specific patterns and negation
3. **File Detection**: Automatically detects programming languages for syntax highlighting
4. **Smart Formatting**: Escapes code blocks properly to prevent Markdown rendering issues
5. **Clipboard Integration**: Uses pyperclip for cross-platform clipboard support
## Configuration
contextr stores its configuration in a `.contextr/` directory in your project:
- `.contextr/state.json` - Current context state and watched patterns
- `.contextr/.ignore` - Custom ignore patterns
- `.contextr/states/` - Saved named states (coming soon)
## Development
```bash
# Install development dependencies
uv sync --extra dev
# Run tests
uv run pytest
# Type checking
uv run pyright
# Linting and formatting
uv run ruff check .
uv run ruff format .
For Developers:
For LLMs:
MIT License
Contributions are welcome! Please feel free to submit a Pull Request.
FAQs
Share your codebase with LLMs - codebase export tool for AI conversations
We found that contextr demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
/Security News
A flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).
Product
Customize license detection with Socket’s new license overlays: gain control, reduce noise, and handle edge cases with precision.
Product
Socket now supports Rust and Cargo, offering package search for all users and experimental SBOM generation for enterprise projects.