Skip to content

Latest commit

 

History

158 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Code Prompts

Command line (and TUI) tool for creating LLM prompts from your code using Handlebars templates.

This was a project to brush up on Rust and is based on code2prompt with some additional functionality that I found useful.


Installation

To download and use the codeprompts command-line tool, you have two options: you can download the release binary or compile from source. For more detailed steps, including setting up tab completions, see the setup guide.

Release Binary

To download a release binary, go to the releases and download the binary for your OS.

Note: In order to use the TUI binary, you will have to add the CLI binary to your path and either:

  • Rename the CLI release binary to codeprompt, or
  • Update the config file for the command to run the CLI binary

Building From Source

To build from source you will need to have git, Rust, and Cargo (will be installed with Rust) installed.

First clone the repository:

git clone git@github.com:seankim658/codeprompts.git

And then compile a release binary:

cd codeprompts/
cargo build --release

Usage

More detailed usage guides can be found here.

Arguments

More extensive documentation on the options can be found here. The code prompts command line tool has the following arguments:

Usage: codeprompt [OPTIONS] [PATH] [COMMAND]

Commands:
  completion  Generate shell completion scripts.
  help        Print this message or the help of the given subcommand(s)

Arguments:
  [PATH]  Path to project directory

Options:
      --profile <PROFILE>       Run using a saved profile from the project-local `.codeprompt.toml`
      --list-profiles           List the profiles defined in the project-local `codeprompt.toml` and exit
      --write-profile[=<NAME>]  Save the flags from this run as a profile, then exit. Use `--write-profile NAME` to name it, or bare `--write-profile` to be prompted
      --delete-profile <NAME>   Delete a saved profile from the project-local `.codeprompt.toml`
      --show-profile <NAME>     Show a saved profile's values and the command it would run
      --force                   Skip the confirmation prompt when overwriting (--write-profile) or deleting (--delete_profile) a profile
      --global                  Operate on global profiles instead of project-local ones
      --include <INCLUDE>       Glob patterns to include
      --exclude <EXCLUDE>       Glob patterns to exclude
      --exclude-priority        Change pattern priority in case of conflict to prioritize the exclusion pattern
      --exclude-from-tree       Eclude files/folders from the source tree based on exclude patterns
      --literal-brackets        Treat `[` and `]` in include/exclude patterns as literal characters rather than glob character classes. Useful for SvelteKit/Next.js dynamic route directories like `[param]`
      --gitignore               Don't respect .gitignore file
  -d, --diff-staged             Capture the git diff for staged changes only (equivalent to running `git diff --cached` or `git diff --staged`
  -u, --diff-unstaged           Capture the git diff for unstaged changes only (equivalent to running `git diff`)
      --no-tokens               Don't display approximate token count of the genrated prompt
  -c, --encoding <ENCODING>     Tokenizer to use for token count [default: cl100k]
  -o, --output <OUTPUT>         Redirect output to file
  -l, --no-line-numbers         Turn off line numbers in source code blocks
      --no-codeblock            Disable wrapping code inside markdown code blocks
      --absolute-paths          Use absolute paths instead of relative paths. Relative paths are the default
      --no-clipboard            Disable copying to clipboard
  -t, --template <TEMPLATE>     Optional path to Handlebars template
      --no-spinner              Whether to render the spinner
      --json                    Whether to print the output as JSON. Defaults to False
      --issue <ISSUE>           Fetch a specific Github issue for the repository
      --verbose                 Run in verbose mode to investigate glob pattern matching
      --no-warnings             Ignore all warnings (sensitive files, large token counts, template warnings)
  -h, --help                    Print help (see more with '--help')
  -V, --version                 Print version

Templates

The templates use a simple templating language called Handlebars.

The pre-defined templates can be downloaded from the project releases. Download the templates.zip.

Currently, the included pre-defined templates are:

Template Name Description
default_template.hbs This is a simple default template that will structure your project path, source tree, and code blocks.
no_tree.hbs The default template without the source tree.
documentation_template.hbs The documentation template creates a prompt for documenting code. The documentation guidelines are consistent with the HIVE lab guidelines and documentation requirements.
git_commit.hbs Template for creating a concise and accurate git commit message. Can be used with both the diff-staged and diff-unstaged options.
git_diff.hbs Simple template that only displays git diff output. Can be used with both diff-staged and diff-unstaged.
git_issue.hbs Template for implementing changes based on a Github issue.
code_optimization.hbs Template for optimizing code in time and space complexity.

Terminal User Interface

TUI

The project also includes an optional TUI wrapper where you can provide a config file to override various flags and see how the command is structured before running it. The TUI also includes a telescope-style fuzzy finder for quick file searching.

About

CLI and TUI tool for generating LLM prompts from your code.

Topics

Resources

Stars

3 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages