---
name: setup
description: Verify local prerequisites and connectivity for Humand product workflow skills
---

# First-Time Setup Wizard

Verifies prerequisites, connectivity, and configuration. Run `/setup` to check your environment.

Walk the user through each check sequentially. After each step, show the result (pass/fail) and, if it failed, provide the exact fix before moving on.

Present a brief intro before starting:

```
## Asistente de Configuración

Verificando tu entorno para que todo funcione a la primera.
```

## Step 1: GitHub CLI

Run:
```bash
gh --version
```

- **Pass**: version string returned.
- **Fail**: install instructions — `brew install gh` (macOS) or https://cli.github.com/.

## Step 2: GitHub Authentication

Run:
```bash
gh auth status
```

- **Pass**: output shows a logged-in account with `HumandDev` org access.
- **Fail**: prompt the user to run `gh auth login` and select the HumandDev org.

## Step 3: GitHub Repo Access

For each repo in the Repositories table in AGENTS.md, run:
```bash
gh api repos/HumandDev/<repo> --jq '.full_name' 2>&1
```

Collect results into a table:

```
| Repo | Estado |
|------|--------|
| humand-main-api | ✓ accesible |
| humand-web | ✗ 404 — verificar membresía de org |
```

- **Pass**: all repos return their full name.
- **Fail**: list the inaccessible repos and suggest the user request access from a GitHub org admin.

## Step 4: Jira API Credentials

Check that Jira REST API credentials are available:

```bash
echo "${JIRA_EMAIL:-${ATLASSIAN_EMAIL:-${JIRA_USERNAME:-${JIRA_USER:-}}}}" | grep -q . && echo "OK" || echo "MISSING"
echo "${JIRA_API_TOKEN:-${ATLASSIAN_API_TOKEN:-${JIRA_TOKEN:-}}}" | grep -q . && echo "OK" || echo "MISSING"
```

- **Pass**: both email and token are set.
- **Fail**: tell the user to set `JIRA_EMAIL` + `JIRA_API_TOKEN` env vars. Token from https://id.atlassian.com/manage-profile/security/api-tokens.

## Step 5: Jira Connectivity

Using the credentials from Step 4, test a search:

```bash
curl -sS -u "${JIRA_EMAIL}:${JIRA_API_TOKEN}" \
  -H "Accept: application/json" \
  --get "https://humand.atlassian.net/rest/api/3/search/jql" \
  --data-urlencode "jql=sprint in openSprints() AND project in (SQRN, SQSH) ORDER BY created DESC" \
  --data-urlencode "maxResults=1" \
  --data-urlencode "fields=summary" | python3 -c "import json,sys; d=json.load(sys.stdin); issues=d.get('issues',[]); print(f'OK — {len(issues)} issue(s) returned') if issues else print('FAIL — no issues (check permissions or active sprint)')"
```

- **Pass**: at least one issue returned.
- **Fail (no creds)**: skip and try Atlassian MCP as fallback (Step 5b).
- **Fail (auth error)**: check credentials or Jira permissions.

### Step 5b: Atlassian MCP (fallback)

Only run if Step 4 failed (no API creds). Attempt to fetch accessible Atlassian resources using the Atlassian MCP `getAccessibleAtlassianResources` tool.

- **Pass**: at least one cloud resource returned (capture the cloud ID). Then test:
  ```
  searchJiraIssuesUsingJql(cloudId, jql: "project in (SQRN, SQSH) ORDER BY created DESC", maxResults: 1)
  ```
- **Fail**: MCP not configured. Tell the user to add the Atlassian MCP server in Cursor settings and authenticate, OR set API credentials (preferred).

## Step 6: Confluence Connectivity

If MCP is available (from Step 5b or independently), test:
```
getConfluenceSpaces(cloudId, limit: 1)
```

If MCP is not available, skip and note that Confluence features (post to Confluence) won't work.

- **Pass**: at least one space returned.
- **Fail**: check Confluence permissions.

## Step 7: Notion MCP

Test Notion MCP connectivity by attempting to search for a page:

Use the Notion MCP `search` tool with a simple query (e.g., `"test"`).

- **Pass**: search returns results or an empty list (connection works).
- **Fail**: MCP not configured or authentication failed. Tell the user to add the Notion MCP in Cursor settings and authenticate via `https://mcp.notion.com/mcp`.

## Step 8: Teams Configuration

Read `config/teams.json` from the workspace.

- **Pass**: file exists, is valid JSON, and contains at least one team with `aliases` and `project_key`.
- **Fail**: file missing or malformed. Show the expected format:
  ```json
  {
    "SQRN": {
      "aliases": ["rhino", "squad-rhino"],
      "project_key": "SQRN",
      "jira_id": "10028",
      "name": "Squad Rhino"
    }
  }
  ```

## Summary

After all steps, show a final scorecard:

```
## Configuración Completa

| # | Verificación | Resultado |
|---|--------------|-----------|
| 1 | GitHub CLI | ✓ |
| 2 | GitHub Auth | ✓ |
| 3 | Acceso a repos (6/6) | ✓ |
| 4 | Jira API creds | ✓ |
| 5 | Jira conectividad | ✓ |
| 5b | Atlassian MCP (fallback) | — skipped |
| 6 | Confluence | ✓ |
| 7 | Notion MCP | ✓ |
| 8 | Config de equipos | ✓ |

Todas las verificaciones pasaron — ¡todo listo!
Probá `/sprint-report rhino` o pedime planificar una funcionalidad.
```

If any checks failed, end with:

```
<N> verificación(es) necesitan atención (marcadas arriba).
Corregí eso y ejecutá `/setup` de nuevo para re-verificar.
```

## Important

- This skill is **read-only**. It never modifies repos, Jira, or Confluence.
- Run all checks sequentially — later steps depend on earlier ones (e.g., Steps 5-6 need the cloud ID from Step 4).
- If a step fails and blocks subsequent steps, skip the blocked steps and mark them as "skipped (depends on step N)".
