A tool to stringify code using rsync and manage presets, forked from rstring.
Project description
Rctx: Rsync-Powered Code Stringification (Fork of Rstring)
Rctx is a developer tool that uses Rsync to efficiently gather and stringify code from your projects. It's designed to streamline the process of preparing code context for AI programming assistants, making it easy to get intelligent insights about your codebase. This is a fork of the original rstring project.
When you run rctx, it copies the selected file contents to your clipboard, prepended with a tree view of the matched files. The output is formatted using Markdown code blocks for easy pasting into LLMs or documents.
Quickly prompt an LLM with your whole project!
Installation
Rctx requires Python 3.8+. We recommend using pipx for installation, as it installs Rctx in an isolated environment, preventing conflicts with other packages.
Using pipx (recommended)
-
Install pipx if you haven't already. Follow the official pipx installation guide for your operating system.
-
Install Rctx:
pipx install rctx
Using pip
If you prefer to use pip, you can install Rctx with:
pip install rctx
Updating Rctx
To update Rctx to the latest version:
With pipx:
pipx upgrade rctx
With pip:
pip install --upgrade rctx
For more detailed information about pipx and its usage, refer to the pipx documentation.
Quick Start
Basic usage (copies tree + content to clipboard):
rctx # Use the default preset
Specify includes/excludes (copies tree + content to clipboard):
rctx --include=*/ --include=*.py --exclude=* # traverse all dirs, include .py files, exclude everything else
Get help:
rctx --help
Use a specific preset:
rctx --preset my_preset
Get a summary view (includes detailed summary, tree, and content, copied to clipboard):
rctx --summary
Advanced Usage
Custom Presets
Create a new preset:
rctx --save-preset python --include=*/ --include=*.py --exclude=* # save it
rctx --preset python # use it
File Preview
Limit output to first N lines of each file:
rctx --preview-length=10
Gitignore Integration
By default, Rctx automatically excludes .gitignore patterns. To ignore .gitignore:
rctx --no-gitignore
Interactive mode:
Enter interactive mode to continuously preview and select matched files:
rctx -i
Understanding Rctx
-
Under the Hood: Rctx efficiently selects files based on filters by running
rsync --archive --itemize-changes --dry-run --list-only <your filters>. This means you can use Rsync's powerful include/exclude patterns to customize file selection. -
Preset System: The default configuration file is at
~/.rctx.yaml. The 'common' preset is used by default and includes sensible exclusions for most projects. -
Output Format (copied to clipboard): A tree view of the selected files is prepended, followed by:
--- path/to/file1.py --- ```python [File contents]--- path/to/file2.js ---
[File contents]
-
Binary Files: Content of binary files is represented as a hexdump preview within a plain code block.
-
Clipboard Integration: Output (tree + content) is automatically copied to clipboard unless disabled with
--no-clipboard. A colored tree is printed to the console. -
Git Integration: By default, Rctx respects .gitignore patterns. Use
--no-gitignoreto ignore them.
Pro Tips
-
Explore the default preset: Check
~/.rctx.yamlto see how the 'common' preset works. -
Refer to Rsync documentation: Rctx uses Rsync for file selection. Refer to the Filter Rules section of the rsync man page to understand how include/exclude patterns work.
-
Customize for your project: Create a project-specific preset for quick context gathering.
-
Use with AI tools: Rctx is great for preparing code context for AI programming assistants, thanks to its Markdown output.
-
Large projects may produce substantial output: Use
--preview-lengthor specific patterns for better manageability.
Development
If you'd like to contribute to Rctx or set it up for local development, follow these steps:
-
Clone the repository:
git clone https://github.com/your-username/rctx.git # Update with your fork's URL cd rctx
-
Create a virtual environment and activate it:
python -m venv venv source venv/bin/activate # On Windows, use `venv\Scripts\activate`
-
Install the development dependencies:
pip install -r requirements-dev.txt
-
Install the package in editable mode:
pip install -e .
This will make the
rctxcommand available in your environment, linked to your local source code. -
Run the tests:
pytest
Running Rctx Locally (after pip install -e .)
Once installed in editable mode, you can run rctx directly:
rctx --help
rctx --include=*.md
Alternatively, without editable install, or to be explicit:
- Make sure you're in the project root directory and your virtual environment is activated.
- Run Rctx using the Python interpreter:
python -m rctx [options]
For example:python -m rctx --include=*/ --include=*.py --exclude=*
Contributing
We welcome contributions to Rctx! Here are some guidelines:
- Fork the repository and create your branch from
main. - If you've added code that should be tested, add tests.
- Ensure the test suite passes.
- Make sure your code lints.
- Issue a pull request!
For more details on contributing, please see our CONTRIBUTING.md file (if one exists, or create one).
Support and Contributing
- Issues and feature requests: GitHub Issues
- Contributions: Pull requests are welcome!
License
Rctx is released under the MIT License. See the LICENSE file for details.
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 rctx-0.8.0.tar.gz.
File metadata
- Download URL: rctx-0.8.0.tar.gz
- Upload date:
- Size: 19.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bcf4f17792ef082e7f24de0874c60b4ea6726ed179c496678fb8a7ede968f434
|
|
| MD5 |
a40254ddcf47bfe5ca27d938e89064e1
|
|
| BLAKE2b-256 |
1e3fe38d395954fa286b16d1415183c09d76e4063cdf1bdeb37c6ca063b212e7
|
Provenance
The following attestation bundles were made for rctx-0.8.0.tar.gz:
Publisher:
package.yml on noreff/rctx
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rctx-0.8.0.tar.gz -
Subject digest:
bcf4f17792ef082e7f24de0874c60b4ea6726ed179c496678fb8a7ede968f434 - Sigstore transparency entry: 214629167
- Sigstore integration time:
-
Permalink:
noreff/rctx@6e28d77528a071f5dd6694a7c9b37426a8f47fde -
Branch / Tag:
refs/heads/main - Owner: https://github.com/noreff
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
package.yml@6e28d77528a071f5dd6694a7c9b37426a8f47fde -
Trigger Event:
push
-
Statement type:
File details
Details for the file rctx-0.8.0-py3-none-any.whl.
File metadata
- Download URL: rctx-0.8.0-py3-none-any.whl
- Upload date:
- Size: 18.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bc3d3a78d2723d7481277c1c38dbf0413494acaf78890af862caf00a8f82d53d
|
|
| MD5 |
3ef0eb0f75e9107beabca4e0eb8cfb30
|
|
| BLAKE2b-256 |
914b82ac50bc76642674710e8e1edea9b694c0f59660a67e2643acb47b82e65c
|
Provenance
The following attestation bundles were made for rctx-0.8.0-py3-none-any.whl:
Publisher:
package.yml on noreff/rctx
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rctx-0.8.0-py3-none-any.whl -
Subject digest:
bc3d3a78d2723d7481277c1c38dbf0413494acaf78890af862caf00a8f82d53d - Sigstore transparency entry: 214629168
- Sigstore integration time:
-
Permalink:
noreff/rctx@6e28d77528a071f5dd6694a7c9b37426a8f47fde -
Branch / Tag:
refs/heads/main - Owner: https://github.com/noreff
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
package.yml@6e28d77528a071f5dd6694a7c9b37426a8f47fde -
Trigger Event:
push
-
Statement type: