From git-tools
This skill should be used when the user asks to "create github repo", "create a new repository", "set up github remote", "configure deploy keys", "init github project", "push to new repo", "create repo with SSH keys", "set up git remote". Creates a GitHub repository, configures SSH deployment keys, and sets up git remote for the current folder.
How this skill is triggered — by the user, by Claude, or both
Slash command
/git-tools:gh-repo-createThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
⚠️ **Important**: This skill generates SSH keys **without passphrases** for convenience. This is suitable for:
⚠️ Important: This skill generates SSH keys without passphrases for convenience. This is suitable for:
Not recommended for: Shared systems, production servers, or CI/CD pipelines.
For enhanced security, consider adding a passphrase when prompted during key generation, or use GitHub Personal Access Tokens (PAT) for automated systems.
When this skill is invoked, follow these steps to initialize a git repository, create it on GitHub, configure SSH deployment keys, and prepare for pushing code:
Before proceeding, ensure the GitHub CLI (gh) is properly installed and authenticated:
Check if gh exists:
which gh || command -v gh
brew install ghCheck authentication status:
gh auth status
gh auth login
Verify required permissions:
repo scope for creating repositoriesCreate the repository using GitHub CLI:
Determine repository visibility (ask user: public or private):
# For public repository
gh repo create <repo-name> --public --source=. --remote=origin
# For private repository
gh repo create <repo-name> --private --source=. --remote=origin
Add repository description (optional, ask user):
gh repo create <repo-name> --public --description "Repository description" --source=. --remote=origin
Verify repository creation:
gh repo view <owner>/<repo-name>
Generate dedicated SSH key pair for this repository:
Create SSH directory if it doesn't exist:
mkdir -p ~/.ssh
chmod 700 ~/.ssh
Generate SSH key pair:
ssh-keygen -t ed25519 -C "deploy-key-<repo-name>" -f ~/.ssh/deploy_<repo-name> -N ""
-N "") for automated deployments~/.ssh/deploy_<repo-name> (private) and ~/.ssh/deploy_<repo-name>.pub (public)Set proper permissions:
chmod 600 ~/.ssh/deploy_<repo-name>
chmod 644 ~/.ssh/deploy_<repo-name>.pub
Verify key generation:
ls -la ~/.ssh/deploy_<repo-name>*
ssh-keygen -l -f ~/.ssh/deploy_<repo-name>.pub
Add a custom SSH host configuration for this repository:
Create or update ~/.ssh/config:
# Create if doesn't exist
touch ~/.ssh/config
chmod 600 ~/.ssh/config
Add host configuration:
# GitHub Deploy Key for <repo-name>
Host github.com-<repo-name>
HostName github.com
User git
IdentityFile ~/.ssh/deploy_<repo-name>
IdentitiesOnly yes
AddKeysToAgent yes
Append to config file safely:
cat >> ~/.ssh/config << 'EOF'
# GitHub Deploy Key for <repo-name>
Host github.com-<repo-name>
HostName github.com
User git
IdentityFile ~/.ssh/deploy_<repo-name>
IdentitiesOnly yes
AddKeysToAgent yes
EOF
Verify configuration:
cat ~/.ssh/config | grep -A 5 "github.com-<repo-name>"
Add the public key to the GitHub repository as a deploy key with write permissions:
Read the public key:
DEPLOY_KEY=$(cat ~/.ssh/deploy_<repo-name>.pub)
Add deploy key via GitHub CLI:
gh repo deploy-key add ~/.ssh/deploy_<repo-name>.pub \
--title "Deploy key for <repo-name> (no expiration)" \
--allow-write \
--repo <owner>/<repo-name>
--allow-write: Enables read/write operations (required for pushing)--title: Descriptive name for the keyVerify deploy key installation:
gh repo deploy-key list --repo <owner>/<repo-name>
Test SSH connection:
ssh -T github.com-<repo-name>
Set up git remotes to use the custom SSH host:
Initialize git repository (if not already done):
git init
Check existing remotes:
git remote -v
Update origin remote to use custom SSH host:
# Remove existing origin if present
git remote remove origin 2>/dev/null || true
# Add new origin with custom SSH host
git remote add origin [email protected]<repo-name>:<owner>/<repo-name>.git
Set upstream tracking:
# Will be used after first push
git branch -M main
Verify remote configuration:
git remote -v
git remote show origin
Perform validation checks without making changes to ensure everything is ready:
Check git status:
git status
main or master)Verify SSH key is accessible:
test -f ~/.ssh/deploy_<repo-name> && echo "✓ Private key exists"
test -f ~/.ssh/deploy_<repo-name>.pub && echo "✓ Public key exists"
Test SSH authentication (non-intrusive):
ssh -T github.com-<repo-name> 2>&1 | grep -q "successfully authenticated" && echo "✓ SSH authentication works"
Verify remote configuration:
git remote get-url origin | grep -q "github.com-<repo-name>" && echo "✓ Remote URL configured correctly"
Check deploy key on GitHub:
gh repo deploy-key list --repo <owner>/<repo-name> | grep -q "Deploy key" && echo "✓ Deploy key is installed"
Test repository accessibility (fetch without pulling):
git ls-remote origin 2>&1 | grep -q "HEAD" && echo "✓ Repository is accessible"
Summary report:
✓ Git repository initialized
✓ GitHub repository created: https://github.com/<owner>/<repo-name>
✓ SSH deployment key generated: ~/.ssh/deploy_<repo-name>
✓ SSH config updated: github.com-<repo-name>
✓ Deploy key added to repository (read/write, no expiration)
✓ Git remote configured: [email protected]<repo-name>:<owner>/<repo-name>.git
✓ SSH authentication successful
Ready to commit and push! Next steps:
1. git add .
2. git commit -m "Initial commit"
3. git push -u origin main
Scenario: You have a local project folder and want to create a new public GitHub repository.
Execution:
# User is in project directory: ~/projects/my-awesome-app
cd ~/projects/my-awesome-app
# User invokes the skill
# Skill prompts: "What would you like to name the GitHub repository?"
# User responds: "my-awesome-app"
# Skill prompts: "Should this be a public or private repository?"
# User responds: "public"
Actions Performed:
gh is installed and authenticated ✓gh repo create my-awesome-app --public --source=. --remote=origin~/.ssh/deploy_my-awesome-app and ~/.ssh/deploy_my-awesome-app.pub~/.ssh/config with host alias github.com-my-awesome-appgh repo deploy-key add ... --allow-write[email protected]:username/my-awesome-app.gitOutput:
✓ GitHub CLI authenticated
✓ Git repository initialized
✓ GitHub repository created: https://github.com/username/my-awesome-app
✓ SSH deployment key generated: ~/.ssh/deploy_my-awesome-app
✓ SSH config updated: github.com-my-awesome-app
✓ Deploy key added to repository (read/write, no expiration)
✓ Git remote configured
✓ SSH authentication successful
Ready to push! Run:
git add .
git commit -m "Initial commit"
git push -u origin main
Scenario: You want to create a private repository with a custom description.
Execution:
cd ~/projects/secret-project
# Skill prompts for:
# - Repository name: "secret-project"
# - Visibility: "private"
# - Description: "Confidential project for internal use"
Actions Performed:
~/.ssh/configResult:
Scenario: You want to create a repository under a GitHub organization.
Execution:
cd ~/projects/company-project
# Skill prompts:
# - Repository name: "company-project"
# - Owner: User selects organization "my-company" instead of personal account
# - Visibility: "private"
Actions Performed:
gh repo create my-company/company-project --private~/.ssh/deploy_company-projectgithub.com-company-projectmy-company/company-project[email protected]:my-company/company-project.gitBenefits:
Below is a complete bash script that implements this skill. This can be used as a reference or executed directly:
#!/usr/bin/env bash
set -euo pipefail
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
# Helper functions
print_success() {
echo -e "${GREEN}✓${NC} $1"
}
print_error() {
echo -e "${RED}✗${NC} $1"
}
print_info() {
echo -e "${YELLOW}→${NC} $1"
}
# Step 1: Get repository name from user
read -p "Enter the GitHub repository name: " REPO_NAME
if [[ -z "$REPO_NAME" ]]; then
print_error "Repository name cannot be empty"
exit 1
fi
# Validate repository name
if [[ ! "$REPO_NAME" =~ ^[a-zA-Z0-9_-]+$ ]]; then
print_error "Invalid repository name. Use only letters, numbers, hyphens, and underscores."
exit 1
fi
print_success "Repository name: $REPO_NAME"
# Step 2: Verify GitHub CLI
print_info "Checking GitHub CLI installation..."
if ! command -v gh &> /dev/null; then
print_error "GitHub CLI (gh) is not installed"
echo "Install it from: https://github.com/cli/cli#installation"
exit 1
fi
print_success "GitHub CLI found: $(gh --version | head -1)"
print_info "Checking authentication status..."
if ! gh auth status &> /dev/null; then
print_error "Not authenticated with GitHub CLI"
echo "Run: gh auth login"
exit 1
fi
print_success "Authenticated with GitHub"
# Get GitHub username
GH_USERNAME=$(gh api user -q .login)
print_info "GitHub username: $GH_USERNAME"
# Step 3: Create repository
read -p "Should this be a public or private repository? (public/private): " VISIBILITY
if [[ "$VISIBILITY" != "public" && "$VISIBILITY" != "private" ]]; then
VISIBILITY="public"
fi
read -p "Enter repository description (optional): " REPO_DESC
print_info "Creating GitHub repository..."
if [[ -n "$REPO_DESC" ]]; then
gh repo create "$REPO_NAME" "--$VISIBILITY" --description "$REPO_DESC" --source=. --remote=origin
else
gh repo create "$REPO_NAME" "--$VISIBILITY" --source=. --remote=origin
fi
print_success "Repository created: https://github.com/$GH_USERNAME/$REPO_NAME"
# Step 4: Generate SSH deployment keys
print_info "Generating SSH deployment keys..."
mkdir -p ~/.ssh
chmod 700 ~/.ssh
SSH_KEY_PATH="$HOME/.ssh/deploy_$REPO_NAME"
if [[ -f "$SSH_KEY_PATH" ]]; then
print_error "SSH key already exists: $SSH_KEY_PATH"
read -p "Overwrite? (yes/no): " OVERWRITE
if [[ "$OVERWRITE" != "yes" ]]; then
print_info "Using existing SSH key"
else
rm -f "$SSH_KEY_PATH" "$SSH_KEY_PATH.pub"
ssh-keygen -t ed25519 -C "deploy-key-$REPO_NAME" -f "$SSH_KEY_PATH" -N ""
print_success "New SSH key generated"
fi
else
ssh-keygen -t ed25519 -C "deploy-key-$REPO_NAME" -f "$SSH_KEY_PATH" -N ""
print_success "SSH key generated"
fi
chmod 600 "$SSH_KEY_PATH"
chmod 644 "$SSH_KEY_PATH.pub"
print_success "Private key: $SSH_KEY_PATH"
print_success "Public key: $SSH_KEY_PATH.pub"
# Step 5: Configure SSH host
print_info "Configuring SSH host in ~/.ssh/config..."
SSH_CONFIG="$HOME/.ssh/config"
touch "$SSH_CONFIG"
chmod 600 "$SSH_CONFIG"
HOST_ALIAS="github.com-$REPO_NAME"
# Check if host already exists
if grep -q "Host $HOST_ALIAS" "$SSH_CONFIG"; then
print_info "Host $HOST_ALIAS already exists in SSH config"
else
cat >> "$SSH_CONFIG" << EOF
# GitHub Deploy Key for $REPO_NAME
Host $HOST_ALIAS
HostName github.com
User git
IdentityFile $SSH_KEY_PATH
IdentitiesOnly yes
AddKeysToAgent yes
EOF
print_success "SSH host configured: $HOST_ALIAS"
fi
# Step 6: Deploy SSH key to GitHub
print_info "Adding deploy key to GitHub repository..."
gh repo deploy-key add "$SSH_KEY_PATH.pub" \
--title "Deploy key for $REPO_NAME (no expiration)" \
--allow-write \
--repo "$GH_USERNAME/$REPO_NAME"
print_success "Deploy key added with read/write access"
# Test SSH connection
print_info "Testing SSH connection..."
if ssh -T "$HOST_ALIAS" 2>&1 | grep -q "successfully authenticated"; then
print_success "SSH authentication successful"
else
print_error "SSH authentication test inconclusive (this may be normal)"
fi
# Step 7: Configure git remote
print_info "Configuring git remote..."
# Initialize git if needed
if [[ ! -d .git ]]; then
git init
print_success "Git repository initialized"
fi
# Remove existing origin if present
git remote remove origin 2>/dev/null || true
# Add new origin with custom SSH host
REMOTE_URL="git@$HOST_ALIAS:$GH_USERNAME/$REPO_NAME.git"
git remote add origin "$REMOTE_URL"
print_success "Git remote added: $REMOTE_URL"
# Set main branch
git branch -M main 2>/dev/null || true
# Step 8: Verify setup
print_info "Verifying setup..."
# Check git status
if git status &> /dev/null; then
print_success "Git repository initialized"
fi
# Check SSH keys
if [[ -f "$SSH_KEY_PATH" ]]; then
print_success "Private key exists: $SSH_KEY_PATH"
fi
if [[ -f "$SSH_KEY_PATH.pub" ]]; then
print_success "Public key exists: $SSH_KEY_PATH.pub"
fi
# Check remote URL
if git remote get-url origin | grep -q "$HOST_ALIAS"; then
print_success "Remote URL configured correctly"
fi
# Check deploy key
if gh repo deploy-key list --repo "$GH_USERNAME/$REPO_NAME" | grep -q "Deploy key"; then
print_success "Deploy key is installed on GitHub"
fi
# Test repository accessibility
if git ls-remote origin &> /dev/null; then
print_success "Repository is accessible"
fi
# Final summary
echo ""
echo "========================================="
echo " Setup Complete!"
echo "========================================="
echo ""
echo "Repository: https://github.com/$GH_USERNAME/$REPO_NAME"
echo "SSH Key: $SSH_KEY_PATH"
echo "SSH Host: $HOST_ALIAS"
echo "Git Remote: $REMOTE_URL"
echo ""
echo "Next steps:"
echo " 1. git add ."
echo " 2. git commit -m \"Initial commit\""
echo " 3. git push -u origin main"
echo ""
npx claudepluginhub j2h4u/oh-my-claude-plugins --plugin git-toolsCreates, edits, and verifies skills using a test-driven development approach with pressure scenarios and subagents.