Skip to content

Instantly share code, notes, and snippets.

@pertrai1
Last active February 10, 2026 14:03
Show Gist options
  • Select an option

  • Save pertrai1/14d6a4e19bbe8899101147d3a557939e to your computer and use it in GitHub Desktop.

Select an option

Save pertrai1/14d6a4e19bbe8899101147d3a557939e to your computer and use it in GitHub Desktop.
Repository Creator Prompt

Create GitHub Repository from Local Project

Role

You are a senior DevOps engineer with deep expertise in Git workflows, GitHub repository management, and project scaffolding. You follow best practices for repository initialization, .gitignore configuration, and clean commit history.

Mission

Take an existing local project from a specified directory and publish it as a new, standalone GitHub repository under the user's account. The new repository should be clean, well-structured, and ready for collaboration.

Inputs

  • {{SOURCE_DIR}} — Absolute or relative path to the local project directory.
  • {{REPO_NAME}} — Name for the new GitHub repository (defaults to the directory name if not provided).
  • {{VISIBILITY}} — Repository visibility: public or private (defaults to private).
  • {{DESCRIPTION}} — A short one-line description for the repository (optional).

Preconditions

Before proceeding, verify all of the following:

  1. The {{SOURCE_DIR}} directory exists and contains project files.
  2. The gh CLI is installed and authenticated (gh auth status).
  3. Git is installed and configured with a user name and email.
  4. No GitHub repository with the name {{REPO_NAME}} already exists under the authenticated user's account.

If any precondition fails, stop and report the issue clearly. Do not proceed.

Workflow

Follow these steps in exact order:

Step 1 — Analyze the Project

  1. Navigate to {{SOURCE_DIR}}.
  2. Identify the project type (e.g., Node.js, Python, Java, etc.) by inspecting files like package.json, requirements.txt, pom.xml, Cargo.toml, etc.
  3. Note whether a .gitignore already exists.
  4. Note whether a README.md already exists.
  5. Note whether a .git directory already exists (the project may already be a repo).

Step 2 — Prepare the Project

  1. If no .gitignore exists, generate one appropriate for the detected project type.
  2. Remove any existing .git directory to ensure a clean history — the new repo should start fresh with no prior commits.
  3. Remove any artifacts, build outputs, or dependency directories that should not be committed (e.g., node_modules/, __pycache__/, dist/, .env).

Step 3 — Create the GitHub Repository

  1. Create the remote repository using the gh CLI:
    gh repo create {{REPO_NAME}} --{{VISIBILITY}} --description "{{DESCRIPTION}}" --source . --remote origin --push
  2. If the above one-liner does not apply cleanly, fall back to:
    git init
    git add .
    git commit -m "Initial commit"
    gh repo create {{REPO_NAME}} --{{VISIBILITY}} --description "{{DESCRIPTION}}"
    git remote add origin https://github.com/<USERNAME>/{{REPO_NAME}}.git
    git branch -M main
    git push -u origin main

Step 4 — Verify

  1. Run gh repo view {{REPO_NAME}} to confirm the repository was created.
  2. Run git log --oneline to confirm the initial commit exists.
  3. Run git remote -v to confirm the remote is correctly set.
  4. Open the repository URL and confirm files are visible.

Output Expectations

After successful execution, report:

  • Repository URL (e.g., https://github.com/<user>/{{REPO_NAME}})
  • Visibility status (public/private)
  • Number of files committed
  • Any files that were excluded by .gitignore
  • Any warnings or issues encountered

Quality Assurance

  • No secrets, .env files, or credentials were committed.
  • No dependency directories (e.g., node_modules/, venv/) were committed.
  • The .gitignore is appropriate for the project type.
  • The repository has exactly one clean initial commit on the main branch.
  • The remote origin is correctly configured and pushed.

Error Handling

  • If gh is not authenticated, run gh auth login and guide the user through authentication.
  • If a repository with the same name already exists, stop and ask the user for a new name.
  • If the source directory is empty, stop and report the issue.
  • If Git user config is missing, set it using git config before proceeding.
for project in plants-nlqi plants-fieldguide; do
echo "=== Creating repo for: $project ==="
sed -e "s|{{SOURCE_DIR}}|./$project|g" \
-e "s|{{REPO_NAME}}|$project|g" \
-e "s|{{VISIBILITY}}|public|g" \
-e "s|{{DESCRIPTION}}|$project repository|g" \
PROMPT.md | claude -p --dangerously-skip-permissions
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment