# dir2prompt
[](https://pypi.org/project/dir2prompt/)
[](https://opensource.org/licenses/MIT)
When you feel too lazy to selectively copy code from all the various files in your project, just copy it all! Inspired by [repo2prompt](https://github.com/andrewgcodes/repo2prompt).
## Installation 💻
You can install `dir2prompt` using pip:
```sh
pip install dir2prompt
```
## Usage 🚀
To generate a prompt from a directory, use the `d2p` command followed by the desired options:
```sh
d2p [directory path] --filters [file extensions] --outpath [output path] --outfile [output file name] --ignore-dir [directories to ignore] --ignore-file [files to ignore] --config [path to config file]
```
For ease of use, you can select a directory by passing it in as a positional argument
```sh
d2p [directory path]
```
## Options ⚙️
`--filter`: File extensions to include in the prompt (default: all files).
`--outpath`: The output path for the prompt file (default: current directory).
`--outfile`: The name of the output file (default: `<directory_name>_prompt`).
`--ignore-dir`: Additional directories to ignore (e.g., `experiments`, `run*`).
`--ignore-file`: Additional file types to ignore (e.g., `pt`, `rs`).
`--config`: Path to a custom config file (default: `config.json` in the package directory).
`--clean`: Remove all `<folder>_prompt.txt` files based on discovered directories.
`--tree`: Only include directory tree in prompt.
`--cp`: Copy prompt to clipboard.
## Example 🌟
Here's an example of how to use `dir2prompt` to generate a prompt:
```sh
d2p --filter py txt md ipynb --ignore-dir experiments __pycache__ --ignore-file old.py
```
This command will generate a prompt for the specified directory, including only files with the extensions `py`, `txt`, `md`, `ipynb`, ignoring the `experiments` and `__pycache__` directories, and ignoring the `old.py` file.
Note that ignored directories are not included in the directory tree, but that ignored files are. However, the content of the ignored files will not be written to the final prompt under the `<files>` tag. This might be changed later...
In this example, the generated prompt will be saved as a `txt` file in the directory that `d2p` is called in with the name `project_prompt.txt`, and will have the following structure:
**<dir_name>_prompt.txt**
```xml
<context>
<directory_tree>
project/
├── README.md
├── requirements.txt
└── src/
├── __init__.py
├── main.py
├── old.py
├── production.ipynb
└── testing.rs
</directory_tree>
<files>
<file>
<path>README.md</path>
<content>
# Project Title
This is an example Python project.
</content>
</file>
<file>
<path>requirements.txt</path>
<content>
numpy==1.21.0
pandas==1.3.0
</content>
</file>
<file>
<path>src/__init__.py</path>
<content>
EMPTY FILE
</content>
</file>
<file>
<path>src/main.py</path>
<content>
import numpy as np
import pandas as pd
def main():
print("Hello, World!")
if __name__ == "__main__":
main()
</content>
</file>
<file>
<path>src/production.ipynb</path>
<content>
---------- Cell 1 (markdown) ----------
### Biologically inspired artificial neuron
$$
y = mx + b
$$
---------- Cell 2 (code) ----------
def neuron(x, m, b):
return m * x + b
</content>
</file>
</files>
</context>
```
You can then feed this prompt into an LLM to provide it with context about your project 🦾
## Config File 📋
`dir2prompt` uses a config file, `config.json`, to list common directories and files that should be ignored and excluded from the prompt. You can customize the behavior by supplying your own config file using the `--config` option:
**example.json**
```json
{
"IGNORE_DIRS": [
"experiments",
"run*",
...
],
"IGNORE_FILES": [
".pt",
".rs",
...
]
}
```
## License 📄
`dir2prompt` is released under the MIT License 🤓
## Contributing 🤝
Contributions are welcome! If you find any issues or have suggestions for improvements, please open an issue or submit a pull request on the GitHub repository.
Raw data
{
"_id": null,
"home_page": null,
"name": "dir2prompt",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": null,
"keywords": "prompt engineering, large language model, directory structure, prompt generation, file tree visualization, directory to prompt, automation tools, developer utilities, code documentation",
"author": null,
"author_email": "Max Kieffer <wkieffer@ufl.edu>",
"download_url": "https://files.pythonhosted.org/packages/fc/b7/505d182f02654141149bec0cfbcad0c4b1eed6fd0895297f337c130c2916/dir2prompt-2.0.8.tar.gz",
"platform": null,
"description": "# dir2prompt\n\n[](https://pypi.org/project/dir2prompt/)\n[](https://opensource.org/licenses/MIT)\n\nWhen you feel too lazy to selectively copy code from all the various files in your project, just copy it all! Inspired by [repo2prompt](https://github.com/andrewgcodes/repo2prompt).\n\n## Installation \ud83d\udcbb\n\nYou can install `dir2prompt` using pip:\n\n```sh\npip install dir2prompt\n```\n\n## Usage \ud83d\ude80\n\nTo generate a prompt from a directory, use the `d2p` command followed by the desired options:\n\n```sh\nd2p [directory path] --filters [file extensions] --outpath [output path] --outfile [output file name] --ignore-dir [directories to ignore] --ignore-file [files to ignore] --config [path to config file]\n\n```\n\nFor ease of use, you can select a directory by passing it in as a positional argument\n\n```sh\nd2p [directory path]\n```\n\n## Options \u2699\ufe0f\n\n`--filter`: File extensions to include in the prompt (default: all files).\n\n`--outpath`: The output path for the prompt file (default: current directory).\n\n`--outfile`: The name of the output file (default: `<directory_name>_prompt`).\n\n`--ignore-dir`: Additional directories to ignore (e.g., `experiments`, `run*`).\n\n`--ignore-file`: Additional file types to ignore (e.g., `pt`, `rs`).\n\n`--config`: Path to a custom config file (default: `config.json` in the package directory).\n\n`--clean`: Remove all `<folder>_prompt.txt` files based on discovered directories.\n\n`--tree`: Only include directory tree in prompt.\n\n`--cp`: Copy prompt to clipboard.\n\n## Example \ud83c\udf1f\n\nHere's an example of how to use `dir2prompt` to generate a prompt:\n\n```sh\nd2p --filter py txt md ipynb --ignore-dir experiments __pycache__ --ignore-file old.py\n```\n\nThis command will generate a prompt for the specified directory, including only files with the extensions `py`, `txt`, `md`, `ipynb`, ignoring the `experiments` and `__pycache__` directories, and ignoring the `old.py` file. \n\nNote that ignored directories are not included in the directory tree, but that ignored files are. However, the content of the ignored files will not be written to the final prompt under the `<files>` tag. This might be changed later...\n\nIn this example, the generated prompt will be saved as a `txt` file in the directory that `d2p` is called in with the name `project_prompt.txt`, and will have the following structure:\n\n**<dir_name>_prompt.txt**\n```xml\n<context>\n<directory_tree>\nproject/\n\u251c\u2500\u2500 README.md\n\u251c\u2500\u2500 requirements.txt\n\u2514\u2500\u2500 src/\n \u251c\u2500\u2500 __init__.py\n \u251c\u2500\u2500 main.py\n \u251c\u2500\u2500 old.py\n \u251c\u2500\u2500 production.ipynb\n \u2514\u2500\u2500 testing.rs\n</directory_tree>\n\n<files>\n\n<file>\n<path>README.md</path>\n<content>\n# Project Title\n\nThis is an example Python project.\n</content>\n</file>\n\n<file>\n<path>requirements.txt</path>\n<content>\nnumpy==1.21.0\npandas==1.3.0\n</content>\n</file>\n\n<file>\n<path>src/__init__.py</path>\n<content>\nEMPTY FILE\n</content>\n</file>\n\n<file>\n<path>src/main.py</path>\n<content>\nimport numpy as np\nimport pandas as pd\n\ndef main():\n print(\"Hello, World!\")\n\nif __name__ == \"__main__\":\n main()\n</content>\n</file>\n\n<file>\n<path>src/production.ipynb</path>\n<content>\n---------- Cell 1 (markdown) ----------\n### Biologically inspired artificial neuron \n\n$$\ny = mx + b\n$$\n\n---------- Cell 2 (code) ----------\ndef neuron(x, m, b):\n return m * x + b\n\n\n</content>\n</file>\n\n</files>\n</context>\n```\n\nYou can then feed this prompt into an LLM to provide it with context about your project \ud83e\uddbe\n\n## Config File \ud83d\udccb\n\n`dir2prompt` uses a config file, `config.json`, to list common directories and files that should be ignored and excluded from the prompt. You can customize the behavior by supplying your own config file using the `--config` option:\n\n**example.json**\n```json\n{\n \"IGNORE_DIRS\": [\n \"experiments\",\n \"run*\",\n ...\n ],\n \"IGNORE_FILES\": [\n \".pt\",\n \".rs\",\n ...\n ]\n}\n```\n\n\n\n\n\n## License \ud83d\udcc4\n\n`dir2prompt` is released under the MIT License \ud83e\udd13\n\n## Contributing \ud83e\udd1d\n\nContributions are welcome! If you find any issues or have suggestions for improvements, please open an issue or submit a pull request on the GitHub repository.\n\n\n\n",
"bugtrack_url": null,
"license": null,
"summary": "Generate prompts for long-context LLMs using the content in your directory",
"version": "2.0.8",
"project_urls": {
"Homepage": "https://github.com/mkieffer1107/dir2prompt",
"Issues": "https://github.com/mkieffer1107/dir2prompt/issues"
},
"split_keywords": [
"prompt engineering",
" large language model",
" directory structure",
" prompt generation",
" file tree visualization",
" directory to prompt",
" automation tools",
" developer utilities",
" code documentation"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "c8f941b6bd1ffca47b8921d64b3253d9e2333c856f180ecbab1f2e6232d5fea8",
"md5": "5986a06ad48bfb18c12756a3e4d0bac4",
"sha256": "6a6ddd6de44ddfc2e472631680acda4c68f02b79514761f30df911ffcc328915"
},
"downloads": -1,
"filename": "dir2prompt-2.0.8-cp39-cp39-macosx_11_0_arm64.whl",
"has_sig": false,
"md5_digest": "5986a06ad48bfb18c12756a3e4d0bac4",
"packagetype": "bdist_wheel",
"python_version": "cp39",
"requires_python": ">=3.6",
"size": 1119769,
"upload_time": "2025-07-17T00:06:50",
"upload_time_iso_8601": "2025-07-17T00:06:50.260507Z",
"url": "https://files.pythonhosted.org/packages/c8/f9/41b6bd1ffca47b8921d64b3253d9e2333c856f180ecbab1f2e6232d5fea8/dir2prompt-2.0.8-cp39-cp39-macosx_11_0_arm64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "fcb7505d182f02654141149bec0cfbcad0c4b1eed6fd0895297f337c130c2916",
"md5": "3b629bd35fa3760d064a308185123409",
"sha256": "41b9c1bf7780bb4dea73c612da6138fb26b15b395f5e9b7ae2ef0c46b36d52df"
},
"downloads": -1,
"filename": "dir2prompt-2.0.8.tar.gz",
"has_sig": false,
"md5_digest": "3b629bd35fa3760d064a308185123409",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 16978,
"upload_time": "2025-07-17T00:06:51",
"upload_time_iso_8601": "2025-07-17T00:06:51.665483Z",
"url": "https://files.pythonhosted.org/packages/fc/b7/505d182f02654141149bec0cfbcad0c4b1eed6fd0895297f337c130c2916/dir2prompt-2.0.8.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-07-17 00:06:51",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "mkieffer1107",
"github_project": "dir2prompt",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "dir2prompt"
}