Skip to content

oleks-dev/prich

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

prich: Prompt Rich LLM Templates with Pre/Postprocessing for Any Workflow

  ██████╗ ██████╗ ██╗ ██████╗██╗  ██╗  Prompt Rich Templating CLI Engine
  ██╔══██╗██╔══██╗██║██╔════╝██║  ██║  For LLM Prompts and Shell Commands
  ██████╔╝██████╔╝██║██║     ███████║  with Multi-Step Processing Pipelines
  ██╔═══╝ ██╔══██╗██║██║     ██╔══██║
  ██║     ██║  ██║██║╚██████╗██║  ██║
  ╚═╝     ╚═╝  ╚═╝╚═╝ ╚═════╝╚═╝  ╚═╝

prich is a lightweight CLI tool for creating, managing, executing, and sharing reusable LLM prompt pipelines for any use case-development, data analysis, content generation, and more. With Jinja2 templating, flexible scripting (in any language), and shareable template packages, prich shines for teams collaborating on standardized LLM workflows. Share templates via files, git, or cloud storage, and streamline tasks like code review, git diff analysis, or CSV data insights.

NOTE: Tool is still under development so there could be potential issues.

Why prich?

  • Any Prompt, Any Domain: Build prompts for coding (e.g., code review), data analysis (e.g., CSV summaries), content creation, or customer support, with preprocessing to prepare data (e.g., parse CSVs, clean text).
  • Team Collaboration: Share template packages via git repos, file transfers, or cloud storage (e.g., Google Drive, Dropbox), ensuring consistent LLM outputs across teams.
  • Simple and Hackable: Intuitive CLI and YAML configs make it easy to craft dynamic prompts, with support for Python, shell, or any scripting language.
  • Portable: Isolated virtual environments (default and custom venvs) ensure dependency safety and portability.

Key Features

  • Modular Prompts: Define prompts with Jinja2 templates and per-template YAML configs.
  • Flexible Pipelines: Chain preprocessing, postprocessing, and llm steps (e.g., parse CSVs, list files) using any language or shell command.
  • Team-Friendly Sharing: Package templates with dependencies for easy sharing via files, git, or cloud storage.
  • Secure venv Management: Default (.prich/venv/) and custom Python venvs (e.g., .prich/templates/code_review/preprocess/venv) isolate dependencies.
  • Simple CLI: Commands like prich run and prich install streamline workflows.

Installation

Set up prich:

Until prich is published on PyPI, you can install it directly from GitHub:

Recommended: Use pipx

pipx install git+https://github.com/oleks-dev/prich

This installs prich in an isolated environment, ideal for CLI tools.
Make sure pipx is installed (pip install pipx && pipx ensurepath).

Alternative: Use uv

uv venv prich-env
source prich-env/bin/activate
uv pip install git+https://github.com/oleks-dev/prich

Manual

git clone https://github.com/oleks-dev/prich.git
cd prich
python -m venv .venv
source .venv/bin/activate
pip install .

Help
To display possible commands

prich --help

Initialize prich:

prich uses nodejs-like home/local folder configurtions for flexible usage of the configs and templates per project.

  • Local folder based

    prich init

    Creates .prich/ with a default preprocessing venv (.prich/venv/) and config file.

  • Global user folder based

    prich init -g

    Creates ~/.prich/ with a default preprocessing venv (~/.prich/venv/) and config file.

Install Templates

There are several ways to install templates. You can install them from remote repository or from local zip archive or template folder. For local option download or clone a template package (e.g., csv_analysis_template/) as a folder or a zip file and install it:

Install template from remote GitHub Template Repository

Templates are stored in this github prich-templates repository

  • List Available Remote Templates for Installation

    prich templates-repo    
  • Install Template from prich-templates Repository

    prich install -r <template_id>
    prich install -r <template_id> -g

Install from a local template zip file:

prich install <template-zip-file>.zip

Install from a local template folder:

prich install <template-folder>
prich install ./code-review

This copies files, sets up venvs, and installs dependencies - if python is used there.

Usage

  • List Templates:
    List both globally (home folder) and locally (current folder) installed templates where local templates overloads any same global

    prich list

    List only globally (home folder) installed templates

    prich list -g

    List only locally (current folder) installed templates

    prich list -l

    Output:

    - git-diff: Analyze and summarize git changes
    - code-review: Review Python files for code quality
    - csv-analysis: Analyze CSV data and generate business insights
    
  • Run a Template:
    See template help description and args

    prich run code-review --help

    Run template

    prich run code-review --file myscript.py

Team Collaboration

prich is designed for teams to share and standardize LLM prompts across workflows:

  • Share Templates in your repository:
    Store .prich/ folder with templates in your repository and work on them together.
    For templates with python preprocess scripts you can add venv folders to .gitignore and ask team to install venvs personally:

    prich venv-install <template_name>

    or to re-install:

    prich venv-install <template_name> --force
  • Share Templates as files: Package templates in a git repo, shared drive, or cloud storage (e.g., Google Drive, Dropbox) You can use complete template folder or compress it into a zip archive.
    Team members install templates:

    git clone https://github.com/your-team/team-prich-templates.git
    prich install team-prich-templates/csv-analysis
    prich install team-prich-templates/code-review.zip

    Or download from cloud storage and install via prich install.

  • Standardize Workflows: Use shared templates to ensure consistent LLM outputs, whether for code reviews (“Add docstrings”) or business insights (“Focus marketing on Laptops”).

  • Cross-Functional Use: Developers, data analysts, marketers, or support teams can use prich for their prompts, with templates tailored to each domain.

Example Templates

id: "explain-code"
name: "Explain Code"
schema_version: "1.0"
version: "1.0"
author: "prich"
description: Provide detailed code explanation
tags: ["code"]
steps:
  - name: "Ask to explain code"
    type: llm
    prompt:
      system: |
        Assistant is a senior engineer who provides detailed code explanation.
      user: |
        Explain what this{% if lang %} {{ lang }}{% endif %} code does:
        File: {{ file }}
        ```{% if lang %}{{ lang.lower() }}{% endif %}
        {{ file | include_file }}
        ```
usage_examples:
  - "explain-code --file mycode.py"
  - "explain-code --file ./mycode.py --lang python"
  - "explain-code --file ./proj/mycode.js --lang javascript"
variables:
  - name: file
    description: File to review
    cli_option: --file
    required: true
    type: str
  - name: lang
    description: Code language (ex. Python, JavaScript, Java)
    cli_option: --lang
    required: false
    default: null
    type: str
id: "summarize-git-diff"
name: "Summarize git diff"
schema_version: "1.0"
version: "1.0"
author: "prich"
description: Generate a summary and review of differences between local code and remote or committed states.
tags: ["code", "git", "diff", "review"]
steps:
  - name: "Run git diff working vs last commit"
    when: "working_vs_last_commit or (not working_vs_last_commit and not working_vs_remote and not committed_vs_remote and not remote_vs_local)"
    type: command
    call: "git"
    args: ["diff", "HEAD"]
    output_variable: "git_diff"

  - name: "Get current branch"
    when: "not working_vs_last_commit"
    type: command
    call: "git"
    args: ["rev-parse", "--abbrev-ref", "HEAD"]
    output_variable: "current_branch"

  - name: "Run git diff working vs remote"
    when: "working_vs_remote"
    type: command
    call: "git"
    args: ["diff", "origin/{{current_branch}}"]
    output_variable: "git_diff"

  - name: "Run git diff committed vs remote"
    when: "committed_vs_remote"
    type: command
    call: "git"
    args: ["diff", "origin/{{current_branch}}..HEAD"]
    output_variable: "git_diff"

  - name: "Run git diff remote vs local"
    when: "remote_vs_local"
    type: command
    call: "git"
    args: ["diff", "HEAD..origin/{{current_branch}}"]
    output_variable: "git_diff"

  - name: "Ask to summarize the diff"
    type: llm
    prompt:
      system: |
        Assistant is a senior engineer who makes a git diff summarization{% if review %} and detailed review{% endif %} in natural language.
      user: |
        Summarize {% if review %} and review {% endif %}the following:
        ```text
        {{ git_diff }}
        ```
usage_examples:
  - "summarize-git-diff"
  - "summarize-git-diff --review"
  - "summarize-git-diff --working-vs-last-commit"
  - "summarize-git-diff --working-vs-last-commit --review"
  - "summarize-git-diff --working-vs-remote"
  - "summarize-git-diff --committed-vs-remote"
  - "summarize-git-diff --remote-vs-local"
variables:
  - name: working_vs_last_commit
    description: "Unstaged working changes"
    cli_option: --working-vs-last-commit
    required: false
    type: bool
  - name: working_vs_remote
    description: "All uncommitted + unpushed vs remote"
    cli_option: --working-vs-remote
    required: false
    type: bool
  - name: committed_vs_remote
    description: "Only unpushed commits"
    cli_option: --committed-vs-remote
    required: false
    type: bool
  - name: remote_vs_local
    description: "Changes on remote not in local"
    cli_option: --remote-vs-local
    required: false
    type: bool
  - name: review
    description: "Make deeper review additionally"
    cli_option: --review
    required: false
    type: bool

Advanced Features

  • Pipeline Steps: Use Python, shell, LLM, or any language for pipeline steps (e.g., parse CSVs with pandas, clean text with awk).

  • Conditional Expressions: Use Jinja2 style conditional expressions to execute or skip pipeline steps

  • Custom Python Venvs: Templates like code_review use dedicated venvs for dependency isolation.

Contributing

Want to create templates for data analysis, content generation, or other domains? Fork the repo, add a template package, or submit a PR! See CONTRIBUTING.md for guidelines.

License

MIT License. See LICENSE for details.


prich: Simplify any LLM prompt pipeline and collaborate effortlessly!

About

CLI tool for LLM prompt pipelines. Reusable. Shareable. Scriptable.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published