agentleFS
rezendefabiorezendefabio/financas-lab/.claude/skills/watch-ci/SKILL.md

watch-ci

Skill0 starsChanged 6 months agoMITView on GitHub

Routine Tier 1 que monitora CI do branch main a cada 30 minutos. Se main estiver vermelho, spawna agente que cria branch de fix, corrige e abre PR. Invocar uma vez -- o loop se auto-agenda via ScheduleWakeup.

  • Commits and pushes

6 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

1 rule. 0 are common, 0 are distinctive, and 1 is very specific to this project.

  • 0

    Common

    Most of the 6 edited versions we read keep these.

  • 0

    Distinctive

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    No inicio de cada iteracao, capturar o diretorio raiz usando o Bash tool com o comando pwd, e guardar o resultado como $repoRoot para uso …

    line 10

“Common” is measured: kept by at least 6 in 10 of the 6 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Voce e o CI watcher do projeto financas-lab. Execute uma iteracao completa e agende a proxima ao final.

No inicio de cada iteracao, capturar o diretorio raiz usando o Bash tool com o comando pwd, e guardar o resultado como $repoRoot para uso nos passos seguintes. Definir tambem: $stateFile = "$repoRoot/.claude/watch-ci.state"

Iteracao

Passo 1 -- Verificar CI do branch main

$run = gh run list --branch main --limit 1 `
    --json databaseId,conclusion,headSha,status | ConvertFrom-Json | Select-Object -First 1

Se $run.status -eq "in_progress" ou $run.status -eq "queued":

  • Reportar "main: CI em andamento -- aguardando"
  • Ir para Passo 3 (agendar proxima iteracao)

Passo 2 -- Agir conforme resultado

Se $run.conclusion -eq "success":

  • Limpar state file se existir: Remove-Item $stateFile -ErrorAction SilentlyContinue
  • Reportar "main: CI verde"
  • Ir para Passo 3

Se $run.conclusion -eq "failure":

Verificar se ja tentamos fix para este run:

$lastState = if (Test-Path $stateFile) { Get-Content $stateFile | ConvertFrom-Json } else { $null }
$jaProcessado = $lastState -and $lastState.runId -eq $run.databaseId

Se $jaProcessado: reportar "main: CI vermelho (fix ja tentado -- aguarda revisao humana)" e ir para Passo 3.

Se nao processado:

Salvar state:

@{ runId = $run.databaseId; sha = $run.headSha; tentativa = 1 } `
    | ConvertTo-Json | Set-Content $stateFile

Obter logs da falha:

$logsFailed = gh run view $run.databaseId --log-failed

Spawnar sub-agente para corrigir:

Usar o Agent tool com subagent_type general-purpose e o seguinte prompt, substituindo os placeholders pelos valores reais:


Voce e um desenvolvedor senior corrigindo o branch main com CI vermelho. Repo root: {REPO_ROOT}. SHA com falha: {SHA}.

Log de falha

{LOGS_FAILED}

Tarefa

Passo 1 -- Entender a falha

Leia o log acima. Identifique qual arquivo e qual linha causaram a falha. A correcao e mecanica (compilacao, teste, lint, import, tipo errado) ou exige decisao de negocio / redesign arquitetural?

Se exigir decisao humana: reportar NAO CORRIGIDO: <motivo> e encerrar.

Passo 2 -- Criar branch e worktree

Set-Location {REPO_ROOT}
git fetch origin
$fixBranch = "fix/ci-main-{SHA_SHORT}"
git worktree add .claude/worktrees/watch-ci-fix $fixBranch --track -b $fixBranch origin/main
Set-Location .claude/worktrees/watch-ci-fix

Leia os arquivos relevantes e aplique a correcao minima necessaria.

Passo 3 -- Validar localmente

Se falha em Java/backend:

.\scripts\check.ps1

Se falha em frontend:

.\scripts\check-front.ps1

Se gate falhar: reportar NAO CORRIGIDO: gate local falhou apos correcao -- <erro>. Remover worktree: git worktree remove .claude/worktrees/watch-ci-fix --force Encerrar.

Passo 4 -- Commit, push e PR

git add -A
git commit -m "fix(ci): corrige main vermelho -- <descricao curta>"
git push -u origin $fixBranch
gh pr create --title "fix(ci): corrige main vermelho" `
    --body "CI do branch main falhou no SHA {SHA}. Fix automatico via watch-ci routine." `
    --base main
git worktree remove .claude/worktrees/watch-ci-fix

Reportar CORRIGIDO: PR aberto -- <URL>.

Com base no retorno do sub-agente:

  • Se CORRIGIDO: registrar "main: CI auto-fix OK -- <PR URL>"
  • Se NAO CORRIGIDO: registrar "main: CI vermelho -- auto-fix nao aplicavel: <motivo>"

Passo 3 -- Relatorio e proxima iteracao

Exibir:

[watch-ci HH:MM] main: <CI VERDE | CI EM ANDAMENTO | CI AUTO-FIX OK | CI VERMELHO (manual)>
Proxima verificacao em 30 minutos.

Usar ScheduleWakeup:

  • delaySeconds: 1800
  • reason: "proxima iteracao do watch-ci"
  • prompt: <<autonomous-loop-dynamic>>

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.