Contextify is a Python script designed to streamline the process of providing context to Large Language Models (LLMs) from your project files. It's particularly useful when working on coding tasks with LLMs, as it can automatically gather and format relevant code from your project.
- Selectively processes files in a directory, respecting
.gitignore
patterns - Focuses on TypeScript files (
.ts
and.tsx
) - Ignores common directories and files that typically don't need to be included
- Outputs processed file contents in Markdown format
- Saves output to a Markdown file
- Python 3.x
-
Place the
contextify.py
file in your project directory or set thedirectory_path
variable in the script to point to your project directory. -
Run the script:
python contextify.py
-
The script will process the files and:
- Print the output to the console
- Save the output to
output.md
in the same directory
You can customize the script by modifying the following variables:
directories_to_ignore
: List of directories to exclude from processingfiles_to_ignore
: List of specific files to exclude from processingextensions_to_include
: List of file extensions to include (currently set to.ts
and.tsx
)
- The script walks through the specified directory and its subdirectories.
- It filters files based on the ignore lists and included extensions.
- For each included file, it reads the content and formats it in a Markdown code block.
- The formatted content is collected in a single string.
- The resulting string is printed, saved to a file.