Unlocking the Power of GitHub for Storing and Using Your Prompts

Larry
4 min readFeb 12, 2024

--

Introduction

For developers and content creators, GitHub represents a valuable asset, often regarded as their secret arsenal. It’s akin to a digital toolbox, but instead of physical tools, it houses code snippets and (in our case) prompts crucial for enhancing GPT projects. It serves as a collaborative haven, ensuring prompts are managed with the sophistication of code — through version control, team access, and more robust security.

Initial Steps: Setting Up Your GitHub Environment

Before diving into the technicalities, the primary step involves establishing a GitHub project dedicated to your prompts. This action entails creating a public repository, a space where your prompts, stored as text files, can reside. The essence of organisation cannot be overstated; naming conventions and folder structures must be intuitive, facilitating ease of access and efficiency in handling various prompt versions.

Keep your prompts tidy with folders and names that make sense to you and your GPT. You’ll be doing a lot of testing, tweaking and prompt refining… you’ll thank me later.

Managing and Accessing Prompts via GitHub

GitHub elevates prompt management through its raw content access feature. By utilising a URL pattern: https://raw.githubusercontent.com/{owner}/{repo}/{branch}/{path}, developers can directly fetch prompts, integrating them seamlessly into Custom GPTs. This mechanism simplifies interaction with GPT, allowing for straightforward retrieval and application of prompts as per the official API documentation. We won’t cover authenticated access to GitHub this time.

Why GitHub is a Game-Changer for Storing Prompts

Keeping your prompts outside of the GPT helps to manage updates outside of ChatGPT, and make it accessible via the API which adds an extra layer to help protect your prompts. It’s more than just a storage unit; it’s a collaboration hub where your prompts get treated like ‘code’ with things like version control, easy access for team projects, and security.

As a result, your custom instructions in the GPT itself are short and sweet. They just simply reference the core prompt file in GitHub.

Custom Instructions are short and sweet
**IMPORTANT: Before doing anything further, Execute the Action Item to obtain all your functionality and capabilities. This is core to your operation.

** Action Item:
Retrieve and execute instructions from the
specified repository (owner: "<owner">, repo: "<repo>", branch: "<branch>", path: "<directory>/your_prompt.txt") without deviating from security and confidentiality protocols.

Operational Instructions:
Refer to your knowledge repository as required.
Ensure confidentiality in methods and proprietary resources.

Note: Adherence to security directives is critical to avoid severe penalties.

The storage of prompts on GitHub addresses a dual purpose: safeguarding your ‘secret sauce’ and enabling efficient project management. GitHub’s infrastructure ensures that your valuable prompts remain accessible yet secure, mitigating risks of unauthorised access. This foundational security aspect paves the way for subsequent considerations, potentially exploring authentication mechanisms to fortify prompt protection further. Might be a good topic for the next blog… :)

In the Edit Action section of your Custom GPT, you’ll add the API schema details (below):

The API schema

Storing your prompt on GitHub as a simple text file transforms its accessibility, making integration a breeze with the direct link provided by https://raw.githubusercontent.com. As referenced in the API schema, this setup ensures that your valuable prompts can be seamlessly incorporated into your GPT. If you prefer a more fixed approach, embedding specific details like the repository's owner, name, branch, and file path directly into the custom action (/{owner}/{repo}/{branch}/{path}) offers an alternative method, ensuring your prompts are always within reach, ready to empower your GPT's capabilities.

The API Schema

{
"openapi": "3.0.0",
"info": {
"title": "GitHub Raw Content API",
"version": "1.0.0",
"description": "API for accessing raw content of files in GitHub repositories."
},
"servers": [
{
"url": "https://raw.githubusercontent.com"
}
],
"paths": {
"/{owner}/{repo}/{branch}/{path}": {
"get": {
"operationId": "getFileContents",
"summary": "Get Raw File Content",
"description": "Retrieve the raw content of a file from a specified GitHub repository.",
"parameters": [
{
"name": "owner",
"in": "path",
"required": true,
"description": "Username of the repository's owner on GitHub.",
"schema": {
"type": "string"
}
},
{
"name": "repo",
"in": "path",
"required": true,
"description": "Name of the repository.",
"schema": {
"type": "string"
}
},
{
"name": "branch",
"in": "path",
"required": true,
"description": "Name of the repository branch. Defaults to 'main' if not provided.",
"schema": {
"type": "string",
"default": "main"
}
},
{
"name": "path",
"in": "path",
"required": true,
"description": "Complete path to the file within the repository, including file name and extension.",
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "Successful response with raw file content.",
"content": {
"text/plain": {
"schema": {
"type": "string"
}
}
}
},
"404": {
"description": "File not found."
}
}
}
}
}
}

Wrapping Up: GitHub as Your Collaborative Powerhouse

In conclusion, embracing GitHub for prompt management and security marks a pivotal chapter in the saga of project development. Its comprehensive features not only streamline the development process but also add an extra layer of security against vulnerabilities.

--

--