pyrompt.github_integration#

GitHub integration for sharing and discovering prompt collections.

Enables:

  • Publishing collections to GitHub repositories

  • Discovering public collections

  • Syncing collections with GitHub

Functions

clone_collection(repo, local_path[, token])

Clone a GitHub collection to local directory.

discover_prompt_collections([search_term, ...])

Discover public *_pyrompt repositories on GitHub.

fork_collection(source, token[, organization])

Fork a collection to your account or organization.

Classes

GitHubPromptCollection(repo, *[, token, ...])

Prompt collection backed by GitHub repository.

class pyrompt.github_integration.GitHubPromptCollection(repo, *, token=None, readonly=True, branch='main', local_cache=None, collection_type='prompts')[source]#

Bases: MutableMapping

Prompt collection backed by GitHub repository.

Repositories must end with ‘_pyrompt’ suffix for discovery. Contains prompts/ and/or templates/ directories.

Examples

>>> # Publishing a collection
>>> gh = GitHubPromptCollection(
...     repo='username/my_prompts_pyrompt',
...     token='ghp_...',
...     readonly=False
... )
>>> gh['greeting'] = "Hello, {name}!"
>>> gh.sync()  # Commits and pushes to GitHub
sync(message='Update prompts via pyrompt')[source]#

Push local changes to GitHub.

Parameters:

message (str) – Commit message

Raises:

PermissionError – If collection is readonly

pyrompt.github_integration.clone_collection(repo, local_path, token=None)[source]#

Clone a GitHub collection to local directory.

Parameters:
  • repo (str) – Repository name (user/repo_pyrompt)

  • local_path (str) – Local directory path

  • token (Optional[str]) – Optional GitHub token

Example

>>> clone_collection(
...     'thorwhalen/awesome_prompts_pyrompt',
...     '/tmp/my_prompts'
... )
pyrompt.github_integration.discover_prompt_collections(search_term=None, min_stars=0, language='Python', max_results=50)[source]#

Discover public *_pyrompt repositories on GitHub.

Parameters:
  • search_term (Optional[str]) – Search query (e.g., “python data”)

  • min_stars (int) – Minimum star count

  • language (str) – Programming language filter

  • max_results (int) – Maximum number of results

Return type:

List[dict]

Returns:

List of dicts with repo info (name, description, stars, url)

Example

>>> collections = discover_prompt_collections(
...     search_term='python',
...     min_stars=5
... )
>>> for repo in collections:
...     print(f"{repo['name']}: {repo['stars']} stars")
pyrompt.github_integration.fork_collection(source, token, organization=None)[source]#

Fork a collection to your account or organization.

Parameters:
  • source (str) – Source repo (user/repo_pyrompt)

  • token (str) – GitHub token with repo permissions

  • organization (Optional[str]) – Optional organization to fork to

Return type:

GitHubPromptCollection

Returns:

GitHubPromptCollection for the new fork

Example

>>> forked = fork_collection(
...     'thorwhalen/awesome_prompts_pyrompt',
...     token='ghp_...'
... )