---
name: publish-to-github
description: Publishes a sandbox to the Humand-CX GitHub organization — creates the repo if it doesn't exist, replaces the git remote, and pushes the current branch. Use when the user wants to move their project off a template/fork remote onto Humand's GitHub.
metadata:
  category: Project Creation
---

# Skill: Publish to GitHub (Humand-CX)

Publishes the current project to a **private** repo under `https://github.com/Humand-CX`, swaps `origin`, and pushes. Supports both cases: repo already created from the GitHub UI, or repo to be created now.

## Prerequisites

Inputs needed:
- **`projectPath`** — repo root (default: current working directory)
- **`repoName`** — name of the target repo (default: project directory name)

Ask only if missing / ambiguous.

## Steps

The mechanical work is delegated to Haiku. The main agent only handles decisions that need judgment (repo existence, user confirmation).

### 1. Preflight (delegate to haiku)

```
Agent({
  model: "haiku",
  prompt: `
    In {projectPath}, run:
    1. gh auth status
    2. git rev-parse --is-inside-work-tree
    3. git remote get-url origin (may not exist — capture null)
    4. git branch --show-current
    5. gh repo view Humand-CX/{repoName} --json name,visibility,url (capture exists:true/false and visibility)

    Report back as a compact summary:
    - ghAuthOk: true/false
    - isGitRepo: true/false
    - currentOrigin: <url or null>
    - currentBranch: <name>
    - repoExists: true/false
    - repoVisibility: <PRIVATE|PUBLIC|null>

    Do not make any changes.
  `
})
```

If `ghAuthOk` is false → stop. Tell user to run `! gh auth login` and re-run.
If `isGitRepo` is false → stop.

### 2. Decide on repo

- **`repoExists: true`** → skip creation. If `repoVisibility` is not `PRIVATE`, warn the user.
- **`repoExists: false`** → ask: *"Did you already create the repo from the UI with a different name, or should I create it now as `Humand-CX/{repoName}` (private)?"*
  - User picks a different name → update `repoName` and re-run step 1 for that name.
  - User wants us to create → continue (Haiku will create it in step 4).

### 3. Confirm plan with the user

Show:
- Target repo: `Humand-CX/{repoName}` (private)
- `currentOrigin` — will be **removed and replaced**
- `currentBranch` — will be pushed with `-u`

Wait for explicit confirmation.

### 4. Execute (delegate to haiku)

```
Agent({
  model: "haiku",
  prompt: `
    In {projectPath}:

    1. If {repoExists} is false: gh repo create Humand-CX/{repoName} --private
    2. If origin exists ({currentOrigin} not null): git remote remove origin
    3. git remote add origin https://github.com/Humand-CX/{repoName}.git
       (HTTPS works with gh's credential helper, set up by gh auth login.
       If the user explicitly prefers SSH, use git@github.com:Humand-CX/{repoName}.git instead.)
    4. git push -u origin {currentBranch}

    Report back:
    - repoUrl: https://github.com/Humand-CX/{repoName}
    - newOrigin: <final origin URL>
    - pushedBranch: {currentBranch}
    - Any errors encountered.
  `
})
```

### 5. Report back

Share repo URL, pushed branch, and new `origin` URL with the user.
