A collection of prompts
Project description
bartste-prompts
A command-line tool to generate prompts for Large Language Models (LLMs) using customizable instruction templates.
Introduction
bartste-prompts is a CLI tool designed for developers to generate prompts for Large Language Models (LLMs). It uses a set of predefined instructions that can be customized per command and per file type. The tool is built with extensibility in mind, allowing users to define their own instructions. The CLI will adapt to custom instructions as a fixed directory structure is assumed.
Key features include:
- Dynamic prompt assembly from markdown instruction templates
- Support for multiple default commands (e.g., explain, fix, refactor, etc.) and file types
- Integration with tools like
aiderfor code editing and explanation - Can be extended with custom instructions
- The CLI adapts to new instructions. No changes in code are necessary.
Installation
You can install bartste-prompts using pip:
pip install bartste-prompts
For development dependencies (testing, linting, etc.), install with:
pip install bartste-prompts[dev]
This will install the prompts command-line tool.
Usage
The basic command structure is:
prompts <command> [options]
Available Commands
The tool comes with these default commands:
docstrings: Generate docstrings for given filesexplain: Explain code functionalityfix: Fix code issuesrefactor: Improve code structuretypehints: Add type hints to codeunittests: Generate unit tests
Common Options
All commands support these options:
--action <tool>: Specify output tool (print,json, oraider)--loglevel <level>: Set logging level (DEBUG,INFO,WARNING,ERROR,CRITICAL)--logfile <path>: Specify log file location
Command-Specific Options
Each command has additional options that correspond to instruction templates. For example:
# Explain command options
prompts explain --files <files> --filetype <type> --user <text>
# Fix command options
prompts fix --files <files> --filetype <type> --user <text>
Examples
Print prompt for explaining Python code:
prompts explain --files main.py --filetype python
Generate JSON output for adding type hints:
prompts typehints --files utils.py --filetype python --action json
Run aider to fix Lua code:
prompts fix --files script.lua --filetype lua --user "Fix memory leak" --action aider
Custom Instructions
You can use custom instructions by specifying the --dir option. The custom directory must follow the same structure as the default _instructions directory. Here's how it works:
Directory Structure
custom_instructions/
├── commands/
│ ├── <command1>/
│ │ ├── command.md
│ │ ├── <key1>.md --> "Text with {value1} as placeholder."
│ │ └── <key2>/
│ │ └── <value2>.md
│ ├── <command2>/
│ │ └── command.md
│ └── ...
└── default/
├── <key1>.md
└── <key2>/
└── <value2>.md
-
commands/: Contains subdirectories for each command (e.g.,
explain,fix, etc.)- Each command directory must contain a
command.mdfile (base instruction) - Additional markdown files or subdirectories correspond to command options (e.g.,
--files,--user, etc.). Here, the files and subdirectories handle the cli values differently:- File: The content of the value can be inserted in the markdown using a python placeholder. For example, for the cli option
--files=foo.py, the "files.md" file contains a placeholder{files}which will be replaced byfoo.py. - Subdirectory: The value represents a filename (without extension) of a markdown file within the subdirectory, which will be read.
- File: The content of the value can be inserted in the markdown using a python placeholder. For example, for the cli option
- Each command directory must contain a
-
default/: Contains fallback instructions in case an instruction is not found in the command directory.
Using a fixed directory structure allows the CLI to adapt to the custom instructions. For example, the directory structure above results in the following CLI:
prompts <command1> --key1 <value1> --key2 <value2>
prompts <command2> --key1 <value1> --key2 <value2>
Here, command2 will fallback to the default directory for options, key1 represents a file, value1 will be inserted in key1.md, key2 represents a directory and value2 is a file within the key2 directory.
Troubleshooting
If you encounter any issues, please report them on the issue tracker at: bartste-prompts issues
Contributing
Contributions are welcome! Please see CONTRIBUTING for more information.
License
Distributed under the MIT License.
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 bartste_prompts-1.0.0.tar.gz.
File metadata
- Download URL: bartste_prompts-1.0.0.tar.gz
- Upload date:
- Size: 21.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9e960d0433d5cbf31e4536c79606cecf0fc0b9bd34db39fb2c90725274f2096d
|
|
| MD5 |
d6e9f5d931fa5ed145b4117bbc3c4302
|
|
| BLAKE2b-256 |
8b1b745c393d4e8d14cf1af40994922bead2c3ecd16ddd5606099d34973c79ae
|
Provenance
The following attestation bundles were made for bartste_prompts-1.0.0.tar.gz:
Publisher:
release.yml on BartSte/bartste-prompts
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
bartste_prompts-1.0.0.tar.gz -
Subject digest:
9e960d0433d5cbf31e4536c79606cecf0fc0b9bd34db39fb2c90725274f2096d - Sigstore transparency entry: 249327421
- Sigstore integration time:
-
Permalink:
BartSte/bartste-prompts@6deabd99cb6963dd93b461305e806b27069261c8 -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/BartSte
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@6deabd99cb6963dd93b461305e806b27069261c8 -
Trigger Event:
push
-
Statement type:
File details
Details for the file bartste_prompts-1.0.0-py3-none-any.whl.
File metadata
- Download URL: bartste_prompts-1.0.0-py3-none-any.whl
- Upload date:
- Size: 29.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9da3dab5c89eabd4d31eaf87037fd5237f51f9fa56feea5ea087134ce44a2743
|
|
| MD5 |
9e65f5e28c4d30df28a22f70f658f47d
|
|
| BLAKE2b-256 |
d25ca42c2aa55bbca088377678d41339aefc75197069290d50cae0591ff69156
|
Provenance
The following attestation bundles were made for bartste_prompts-1.0.0-py3-none-any.whl:
Publisher:
release.yml on BartSte/bartste-prompts
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
bartste_prompts-1.0.0-py3-none-any.whl -
Subject digest:
9da3dab5c89eabd4d31eaf87037fd5237f51f9fa56feea5ea087134ce44a2743 - Sigstore transparency entry: 249327423
- Sigstore integration time:
-
Permalink:
BartSte/bartste-prompts@6deabd99cb6963dd93b461305e806b27069261c8 -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/BartSte
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@6deabd99cb6963dd93b461305e806b27069261c8 -
Trigger Event:
push
-
Statement type: