---
name: hu-team-staging-status
description: Generate per-repo staging and develop status for a team and publish to Notion
---

# Team Staging & Develop Status (Jira-first → Notion)

Per-repo summary of what's in staging vs develop for a team, plus what entered the latest production release. Jira is the source of truth for ticket linkage. Output goes to a Notion page.

## How it works

1. **Python script** fetches data (GitHub branches + Jira tickets + Jira dev-info), classifies PRs, computes latest prod release delta, outputs markdown to stdout
2. **Agent** creates a Notion page with that markdown via the Notion MCP, returns the page link

## Step 1 — Run the script

Resolve the team without loading full `config/teams.json`:

```bash
bash scripts/get-team-config.sh --team "raccoon" --format env
```

Then run:

```bash
TEAM_NAME="Raccoon" \
TEAM_TICKET_PREFIX="SQRC" \
python3 skills/hu-team-staging-status/team-staging-status.py
```

### Required env vars

| Var | Example | Source |
|-----|---------|--------|
| `TEAM_NAME` | `Raccoon` | Display label |
| `TEAM_TICKET_PREFIX` | `SQRC` | Jira project key |
| `JIRA_EMAIL` | `cursor.bot@humand.co` | Jira auth |
| `JIRA_API_TOKEN` | (token) | Jira auth |

Fallbacks: `ATLASSIAN_EMAIL`, `ATLASSIAN_API_TOKEN`, `JIRA_BASE_URL` / `ATLASSIAN_BASE_URL`.

### Optional env vars

- `HUMAND_GH_ORG` (default: `HumandDev`)
- `RELEASE_REPOS` (default: `humand-web humand-backoffice humand-main-api`)
- `VERSION_REPOS` (default: `humand-mobile`)
- `TEAM_GITHUB_MEMBERS` (comma-separated github logins; overrides config-based team roster for prod filtering)
- `TEAM_STATUS_DEBUG=1` — debug logs to stderr

### Output

The script prints a full markdown report to stdout:
- Title + date
- Summary table (repo × staging / develop-only / open PRs)
- "Ultimo release a produccion" section with:
  - prod reference used per repo (`prod` vs `prev_prod`)
  - total PRs detected in that release window (when comparable)
  - team PRs filtered by team roster (author login), team tickets, and team PRs without ticket
  - hotfix/stgfix team PRs (from GitHub PR labels)
- Staging section grouped by repos
- Develop section grouped by repos
- Open PRs section grouped by repos
- "Sin PRs vinculados" section for active tickets with no linked PRs

## Step 2 — Create Notion page

Using the **Notion MCP**, create a page with the markdown output from step 1.

1. Search for an existing page titled `Estado staging — <TeamName>` in the team's workspace. If found, **update it** instead of creating a new one.
2. If not found, **create a new page**.
3. The page title should be: `Estado staging — <TeamName> (<YYYY-MM-DD>)`
4. The page body is the raw markdown output from the script.
5. If Notion publish succeeds, return **only** the Notion page URL to the user (do not paste the raw markdown in chat).
6. If Notion MCP fails (unavailable, timeout, auth/permission error, or write error), return the raw markdown report in chat as fallback and explicitly mention that Notion publish failed.

## Output language

Agent-generated summary, commentary, or section headers must be in **Spanish**.
