Skip to main content

A tool to generate context files from multiple files and folders.

Project description

🚀 mycontext

PyPI Version Build Status License: GPL v3 Python Versions

Supercharge your interactions with LLMs by effortlessly creating clean, complete, and personalized context files directly from your source code.

mycontext is a command-line tool (CLI) designed to eliminate the tedious task of copying and pasting code into large language models. It intelligently collects, filters, and formats your project's files into a single optimized prompt, ready for analysis.

Demo Gif Placeholder


🤔 Why mycontext?

Copying and pasting code into LLMs is a slow and error-prone process:

  • You forget important files.
  • You include unnecessary files (node_modules, .pyc).
  • You lose formatting or structure.
  • You have to rewrite the same instructions over and over.

mycontext automates this workflow, allowing you to:

  • Save Time: Generate a complete context in seconds.
  • Improve Quality: Well-structured prompts produce better LLM responses.
  • Be Consistent: Use reusable rule profiles to ensure the LLM always receives the same guidelines.
  • Work Faster: Send the context directly to your clipboard and paste it into your LLM.

✨ Key Features

  • Smart Collection: Recursively scans directories and collects files.
  • Exclusion Rules: Comes with a sensible default list of files and folders to ignore (like .git, __pycache__), fully customizable.
  • Rule Profiles (Powerful!): Define how the LLM should behave with .md files. Use the default profile or specify one on the fly for different tasks (e.g., security_audit.md, refactor_code.md).
  • Clipboard Integration: Why save a file? Send the context directly to your clipboard with the -c option.
  • Simple Management: Intuitive commands to add/remove/list your exclusion and context rules.
  • Modular and Extensible: The command architecture makes it easy to add new features.

📦 Installation

Prerequisites (for Linux users)

On Debian-based systems (like Ubuntu), you may need to install the python3-venv package, which is required to create virtual environments:

sudo apt update && sudo apt install python3-venv

You can install mycontext using pip (for Python environments) or npm (for Node.js environments).

With pip

pip install mycontext

With npm

npm install -g mycontext-node

⌨️ Usage and Commands

Quick Guide

# 1. Generate a context from the current directory into a text file
mycontext .

# 2. Generate context and copy it directly to the clipboard (most used)
mycontext . -c

# 3. Use a specific rule profile for generation
mycontext ./src --rules ./docs/refactoring_rules.md

# 4. Generate context without applying any rules
mycontext . --no-rules

# 5. Combine everything: generate from 'src' with a profile and copy to clipboard
mycontext ./src --rules security_audit.md -c

Command Reference

Project-Specific Ignores with .mycontext-ignore

For more granular control, you can define ignore rules on a per-project basis by creating a .mycontext-ignore file in the root directory of your project.

If this file is present, it will take highest priority, overriding any global or default settings. The add-ignore and remove-ignore commands will not affect this file; it must be managed manually.

The .mycontext-ignore file must be a JSON file with the same structure as the default ignore configuration.

Example .mycontext-ignore:

{
  "names": [
    "dist",
    "build",
    "docs"
  ],
  "patterns": [
    "*.test.js",
    "temp_*"
  ],
  "extensions": [
    ".env"
  ]
}

Generate Context

The default command. Runs if no other is specified.

  • mycontext [paths...]: Generates context from the specified paths.
  • -o, --output [FILENAME]: Saves the output to a specific file.
  • -r, --rules [RULES_FILE.md]: Uses a custom rule profile for this run.
  • -c, --to-clipboard: Copies the output to the clipboard instead of a file.
  • --no-rules: Generates the context without including any rules file.

Manage Exclusion Rules (Ignores)

  • mycontext list-ignore: Displays the current exclusion rules.
  • mycontext add-ignore [name|pattern|ext] [value]: Adds a new rule to custom_ignore.json.
    • mycontext add-ignore name "dist"
  • mycontext remove-ignore [name|pattern|ext] [value]: Removes a rule from custom_ignore.json.
    • mycontext remove-ignore ext ".log"

Manage Context Rules

  • mycontext list-rules: Displays the active context rules (either custom or default).
  • mycontext add-rule "[CONTENT]": Adds a new line of text to the context_rules.md file.
  • mycontext update-rules: Opens context_rules.md in your default text editor ($EDITOR).
  • mycontext remove-rules: Deletes your custom context_rules.md file (reverts to the default).

🤝 Contributions

Contributions are welcome! If you have ideas for new features, improvements, or have found a bug, please open an issue on GitHub or submit a pull request.

📜 License

This project is licensed under the GNU General Public License v3 License. See the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mycontext-0.1.12.tar.gz (27.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mycontext-0.1.12-py3-none-any.whl (29.3 kB view details)

Uploaded Python 3

File details

Details for the file mycontext-0.1.12.tar.gz.

File metadata

  • Download URL: mycontext-0.1.12.tar.gz
  • Upload date:
  • Size: 27.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for mycontext-0.1.12.tar.gz
Algorithm Hash digest
SHA256 686f7653cfc4a3a4c8ceaf554c5f452a589f55ebf3b49b6ab235213d206b72e8
MD5 ed2f1f2db2077ad9fcba2d4d8ee096a9
BLAKE2b-256 1084e2151e3a7e3e4127957b3b611018ca1a4c97608bb6edd5a9e5c3b8c0a7f4

See more details on using hashes here.

File details

Details for the file mycontext-0.1.12-py3-none-any.whl.

File metadata

  • Download URL: mycontext-0.1.12-py3-none-any.whl
  • Upload date:
  • Size: 29.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for mycontext-0.1.12-py3-none-any.whl
Algorithm Hash digest
SHA256 437f1eadb9d5dd18f782b7e39d23ed1d60893982dfce73fdc03d02ffe4d73f50
MD5 ea2d1bc3a4210c62cf9a16a1ec9e4f19
BLAKE2b-256 88647d908228254b20884a5b29fb3f79a00e247dce465c6e28a495a89e78ba8c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page