{"id":51116142,"url":"https://github.com/hey1me/prompt-library","last_synced_at":"2026-06-24T22:00:58.614Z","repository":{"id":365714894,"uuid":"1273407075","full_name":"hey1me/Prompt-Library","owner":"hey1me","description":"Lightweight Local Prompt Library by using python","archived":false,"fork":false,"pushed_at":"2026-06-18T13:57:45.000Z","size":12,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-06-18T15:32:33.652Z","etag":null,"topics":["ai","library","local-first","management","prompt","python3"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hey1me.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-06-18T13:47:23.000Z","updated_at":"2026-06-18T13:59:55.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/hey1me/Prompt-Library","commit_stats":null,"previous_names":["hey1me/prompt-library"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/hey1me/Prompt-Library","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hey1me%2FPrompt-Library","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hey1me%2FPrompt-Library/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hey1me%2FPrompt-Library/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hey1me%2FPrompt-Library/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hey1me","download_url":"https://codeload.github.com/hey1me/Prompt-Library/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hey1me%2FPrompt-Library/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34750953,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-24T02:00:07.484Z","response_time":106,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai","library","local-first","management","prompt","python3"],"created_at":"2026-06-24T22:00:57.583Z","updated_at":"2026-06-24T22:00:58.604Z","avatar_url":"https://github.com/hey1me.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Prompt Library\n\n\u003e A local library to store, organize, and manage reusable AI prompt templates.\n\n`pl` is a command-line prompt manager that lets you build a personal collection of prompt templates — organized by category, searchable by keyword or tag, and renderable with variable substitution. Powered by **SQLite with FTS5 full-text search** for fast, deterministic local storage.\n\n---\n\n## Features\n\n- **SQLite-backed storage** — prompts live in a local SQLite database, not loose files. YAML files are used only for import/export.\n- **FTS5 full-text search** — BM25-ranked search with Porter stemming, prefix wildcards, and usage-based scoring.\n- **Variable substitution** — define `{{variables}}` in templates and render them via `--var` flags or interactively.\n- **Model hints** — tag prompts with the models they work best with.\n- **Import / Export** — bulk-import YAML prompt files into SQLite, and export back out for sharing.\n- **Ledger audit trail** — optional append-only transaction log enabled via `PROMPT_LIBRARY_LEDGER=1`.\n- **Simple CLI** — one command (`pl`) for everything.\n\n---\n\n## Setup\n\n### Requirements\n\n- Python 3.10+\n- pip\n\n### Install\n\n```bash\ngit clone https://github.com/hey1me/Prompt-Library.git\ncd Prompt-Library\npython3 -m venv .venv\nsource .venv/bin/activate\npip install -e .\n```\n\nThat's it. The `pl` command is now available globally.\n\n---\n\n## Usage\n\n```bash\n# List all prompts\npl list\n\n# Filter by category\npl list --category development\n\n# Search by keyword or tag\npl search \"code review\"\n\n# Show a prompt's full content\npl get code-review\n\n# Render a prompt (interactive or with --var flags)\npl render code-review\npl render code-review --var language=python --var code_snippet=\"...\"\n\n# Add a single prompt from a YAML file\npl add my-prompt.yaml\n\n# Bulk-import all YAML prompts from a directory\npl import --dir prompts/\n\n# Export database to YAML files\npl export --dir ./export\n\n# List all categories with prompt counts\npl categories\n\n# Show database statistics\npl info\n\n# Optimize the database (rebuild FTS index + VACUUM)\npl optimize\n```\n\n---\n\n## Prompt Format\n\nPrompts are defined as YAML files with frontmatter metadata and a body template. These serve as the **import/export format**; actual storage is in SQLite.\n\n```yaml\nid: my-prompt\ntitle: My Prompt Title\ndescription: What this prompt does\ncategory: development\ntags: [tag1, tag2]\nmodel_hint: claude, gpt4\nvariables:\n  - name: variable_name\n    description: What this variable represents\n    default: optional_default\nversion: \"1.0\"\ncreated: 2026-01-01\nupdated: 2026-01-01\n---\nYour prompt template goes here.\n\nUse {{variable_name}} for substitution.\n```\n\nThe `---` separator divides frontmatter (YAML metadata) from the prompt body.\n\n---\n\n## Project Structure\n\n```\nPrompt-Library/\n├── pl/                  # CLI source code\n│   ├── commands.py      # Click command definitions\n│   ├── database.py      # SQLite connection \u0026 schema (FTS5)\n│   ├── ledger.py        # Optional audit trail\n│   ├── migrations.py    # Schema migrations\n│   ├── models.py        # Pydantic prompt data models\n│   ├── renderer.py      # Variable substitution engine\n│   ├── search.py        # FTS5 search with BM25 + usage scoring\n│   └── storage.py       # SQLite CRUD, YAML import/export\n├── prompts/             # Example prompt library (YAML source files)\n│   ├── analysis/\n│   ├── development/\n│   └── writing/\n├── tests/               # Test suite (pytest)\n│   ├── conftest.py\n│   ├── fixtures/prompts/\n│   └── test_*.py\n├── pl.py                # Entry point\n└── pyproject.toml\n```\n\n---\n\n## Adding Your Own Prompts\n\n### Option 1: Add a single YAML file\n\n```bash\npl add path/to/my-prompt.yaml\n```\n\nThe prompt is parsed, validated, and inserted into the SQLite database.\n\n### Option 2: Bulk-import a directory\n\n```bash\npl import --dir prompts/\n```\n\nScans the directory recursively for `*.yaml` files, parses frontmatter, and inserts each one. **Duplicate IDs are silently skipped**, making imports idempotent.\n\n### Option 3: Manual database insert\n\n```bash\npl import --dir path/to/my-prompts/\n```\n\n---\n\n## Search\n\nThe search engine uses **FTS5 BM25 ranking** combined with a usage-based weight:\n\n```\nFinal Rank = BM25_text_score + (log10(fetch_count + 1) * user_rating)\n```\n\nThe fallback chain ensures you always get results:\n\n1. **FTS5 AND query** — exact match on all terms with BM25 ranking\n2. **Prefix wildcard OR** — `term*` on each term when AND returns nothing\n3. **LIKE scan** — last resort scan on title and description columns\n\nUsage scoring means frequently fetched, highly-rated prompts rank higher — the system gets smarter the more you use it.\n\n---\n\n## Environment Variables\n\n| Variable | Description | Default |\n|---|---|---|\n| `PROMPT_LIBRARY_DB` | Path to the SQLite database | `~/.local/share/prompt-library/library.db` |\n| `PROMPT_LIBRARY_LEDGER` | Enable audit trail (`1` to enable) | disabled |\n| `XDG_DATA_HOME` | Base directory for XDG data (DB location) | `~/.local/share` |\n\n---\n\n## Database\n\nThe database is stored at `~/.local/share/prompt-library/library.db` (XDG-compliant). It uses:\n\n- **WAL journal mode** for concurrent reads\n- **FTS5 virtual table** for full-text search\n- **Triggers** to keep the FTS index in sync on INSERT/UPDATE/DELETE\n- **Porter stemmer** for English word stemming (e.g., \"reviewing\" → \"review\")\n\nRun `pl optimize` periodically to rebuild the FTS index and reclaim space.\n\n---\n\n## Contribution\n\n\u003e [!NOTE]\n\u003e If you are interested in adding features, feel free to open a Pull Request.\n\n---\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhey1me%2Fprompt-library","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhey1me%2Fprompt-library","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhey1me%2Fprompt-library/lists"}