Empezar

Reglas comunes

Las normas de trabajo que el plugin carga al empezar cada sesión: git, calidad, merge requests, CI, releases y pruebas en local. Aquí están explicadas en español; el texto original del plugin está al final de la página.

Fuente: plugins/hanzo-web/context/core.md · hanzo-web v0.2.0

En esta página

En resumen

  • Al empezar, pregunta qué tarea de Jira usar.
  • Cada tarea se hace en su propio worktree.
  • Antes de un MR, pasa el gate de CodeClimate en local (0 major / ≤ 2 minor nuevos).
  • La descripción del MR va en inglés y con la plantilla común.
  • Nunca crea un MR, hace push o lanza un pipeline sin preguntarte.

Estas reglas se aplican en todos los proyectos web de Hanzo preparados con /hanzo-web:init, tanto en Claude Code como en Cursor.

  • Los datos propios de cada proyecto (arquitectura, sitios, content types, URLs) están en el CLAUDE.local.md del checkout principal. Si contradice estas reglas, manda CLAUDE.local.md.
  • En Cursor, skills y agentes se usan sin el prefijo hanzo-web: (/release, /code-reviewer), y CLAUDE.local.md no se carga solo: el agente lo lee al empezar cada tarea.

Agentes y skills

Qué agente o skill usar en cada momento:

Agente Cuándo
architect · solo lectura Antes de programar cualquier tarea no trivial: un bloque nuevo, un componente compartido, un refactor.
usage-finder · solo lectura Antes de cambiar algo compartido, o para saber qué páginas usan un bloque.
nextjs-frontend Para crear o cambiar módulos, componentes, rutas, SEO o lógica multisitio.
strapi-cms Cuando el front necesita un campo o un bloque nuevo, o hay que tocar Strapi.
scss-styles Trabajo visual, paso de Figma a código, temas o errores de Stylelint.
unit-tests Para escribir o arreglar tests, o entender por qué falla la suite.
code-reviewer · solo lectura Siempre, con el código terminado y antes de proponer el MR.
qa-parity Tras cualquier cambio que afecte al render, al CSS, al JS, a las rutas o al build.
perf-seo-a11y LCP, CLS o INP, peso de imágenes, etiquetas SEO, sitemaps o fallos WCAG.
build-devops Pipelines que fallan, Docker, scripts de build o despliegue y variables de entorno.
Skill Para qué
/hanzo-web:ci-status Te dice cómo va el CI de una rama, un MR o un pipeline y, si algo falla, por qué.
/hanzo-web:clean-worktrees Borra con seguridad los worktrees de tareas ya mergeadas en develop, junto con sus ramas locales.
/hanzo-web:init Prepara un proyecto para usar el plugin: detecta cómo está hecho, te pregunta lo que falta y genera su contexto local.
/hanzo-web:jira-task Lleva una tarea de Jira de principio a fin: desde leer la issue hasta proponerte el MR.
/hanzo-web:preview-local Levanta el proyecto en local, abre las páginas afectadas, las compara con PRE y te explica cómo comprobar el cambio.
/hanzo-web:release Prepara la release del día: la rama release/vDD_MM_YY, el cambio de versión y sus dos MRs, a producción y a develop.

Las tareas de un solo módulo van más rápido en la sesión principal. Los agentes que más aportan son los de solo lectura, porque empiezan con el contexto limpio: architect al principio, usage-finder para medir el impacto, y code-reviewer y qa-parity al final.

Al encargar algo a un agente, pásale la ruta del worktree, los criterios de aceptación de Jira y las decisiones que ya has tomado. Al revisor, dale el código, no tus conclusiones.

Al empezar la sesión

Antes de hacer nada, el agente te pregunta si la sesión corresponde a una tarea del tablero de Jira del proyecto (jira.key).

Si le das una:

  • Lee la issue con las herramientas de Atlassian.
  • Usa su clave en el nombre de la rama y en el título del MR: [KEY-123] <Título>.
  • Los mensajes de commit no llevan la clave.

Flujo de git

  • Un worktree por tarea, en worktrees.dir/<slug>, con la rama feature/<KEY-123>-<slug> (o fix/… para bugs) creada desde origin/<git.develop> recién actualizado. Nunca se cambia de rama en el checkout principal para hacer una tarea.
  • En el worktree, node_modules de la app Next es un enlace al del checkout principal. El .env solo se copia si vas a arrancar Next.
  • Push solo al remote configurado (gitlab.remote, en gitlab.host). A otro remote, nunca sin preguntar.
  • Títulos cortos: el asunto del commit y el título del MR, idealmente por debajo de unos 50 caracteres. El detalle va en el cuerpo o en la lista de cambios.
  • Antes de borrar o sustituir algo que parezca generado o raro (un sitemap versionado, un fichero antiguo), mira con git log --follow -- <fichero> por qué existe.

Calidad del código (CodeClimate)

Obligatorio en cada feature y cada bugfix. El CI ejecuta code_quality y quality_gate, y el MR falla si hay más de 0 problemas major o más de 2 minor nuevos respecto a develop.

Qué se comprueba:

  • Más de 4 argumentos por función, más de 25 líneas por función o más de 250 por fichero.
  • Complejidad cognitiva mayor que 5; más de 4 niveles de anidamiento, de return o de lógica compleja.
  • Código duplicado (JavaScript) y las reglas ESLint por defecto de CodeClimate en ficheros .js.
  • Comentarios TODO, FIXME, HACK, XXX o BUG.

Quedan fuera las carpetas de tests, los *.d.ts y los *.min.js.

Cómo trabajar con él:

  1. Pásalo en local cuando el código esté terminado y pasen lint y tests:

    node <scripts del plugin>/quality-gate-local.mjs <ruta-del-worktree>

    Compara tus cambios (incluidos los no commiteados) con develop. --all lista todos los problemas y --base <ref> cambia la referencia.

  2. Corrige los problemas nuevos, con el objetivo de dejar 0, no solo de no pasar de 2: divide componentes y funciones, extrae helpers, reduce anidamiento y duplicación. No refactorices código que no tiene que ver con la tarea, y diseña ficheros pequeños desde el principio.

  3. Cada fichero .js nuevo suma 2 minor ("rule not found") en el CI. Añádelo al .eslintignore de la app Next o, mejor, usa .ts / .tsx.

  4. Informa del resultado al terminar, por ejemplo: "CodeClimate: 0 major / 1 minor nuevos → PASS". Pásalo antes de cualquier MR, aunque el cambio no tenga JS. La última palabra la tiene el job quality_gate del CI.

Normas para cualquier cambio

  • Un campo nuevo del CMS que cambia el comportamiento empieza con el comportamiento de hoy (booleano a false), para que el contenido existente se vea exactamente igual.
  • Los cambios de rendimiento, SEO o refactor no deben cambiar cómo se ve ni cómo funciona la web. Planifica una comprobación de paridad con PRE.
  • En proyectos con export estático no hay API routes, getServerSideProps ni middleware, y el uso de window y document va protegido.
  • Antes de cambiar un componente compartido o una clase SCSS global, lista todos los sitios donde se usa.
  • Nunca se commitea .env, la base de datos de Strapi (.tmp/data.db), public/uploads, la salida del build ni los ficheros de Claude (CLAUDE.local.md, .claude/).

Merge requests

Cuando la tarea está terminada y ha pasado CodeClimate, el agente te pregunta si abre el MR contra git.develop. Nunca lo crea sin tu confirmación. El MCP de GitLab no puede editar un MR después de crearlo, así que título, rama destino y descripción tienen que estar bien desde el principio.

La descripción te la da como bloque de Markdown en el chat (no como fichero), salvo que pidas otra cosa. Va siempre en inglés, con esta plantilla:

md
## [KEY-123] <Title: one-line summary of the task's goal>

<Link to the Jira issue>

### Changes
- **<Change 1>**: brief explanation of what was changed and why.
- **<Change 2>**: brief explanation of what was changed and why.

Con tarea de Jira, la clave va delante del título, tanto en el campo de título del MR como en el encabezado ##. Sin tarea, se quitan la clave y el enlace.

Estado del CI (GitLab)

Para consultar pipelines y jobs se usa, por este orden, lo primero que esté disponible:

  1. El MCP de GitLab, si la sesión lo tiene.
  2. La CLI glab (glab ci status, glab ci view, glab ci trace <job>).
  3. La API REST con un token del entorno (GITLAB_TOKEN).

Los tokens nunca se muestran, se guardan ni se commitean, y nunca se te pedirá que pegues uno en el chat. Por defecto solo se consulta: reintentar, cancelar o lanzar pipelines o jobs manuales requiere preguntarte antes. El procedimiento completo está en /hanzo-web:ci-status.

Releases

Se hacen con /hanzo-web:release. En resumen:

  • Rama release/vDD_MM_YY con la fecha de hoy, creada desde origin/<git.develop> en un worktree.
  • El único cambio es poner 'DD-MM-YY' en la constante de versión (release.versionConst, en release.versionFile), con el commit Bump version to vDD_MM_YY.
  • Dos MRs, a git.production y a git.develop, titulados Release vDD_MM_YY. Su lista de cambios son los títulos de los MRs mergeados desde la última release.
  • En los dos, "Squash commits" y "Delete source branch" desmarcados.

Si después de mergear se olvidó un MR, nunca se reescriben git.production ni git.develop: se avanza la rama de release y se sube la versión a DD-MM-YY+1.

Pruebas visuales en local

Se hacen con /hanzo-web:preview-local. Reglas clave:

  1. Strapi, siempre desde el checkout principal. Al arrancar, Strapi ajusta la base de datos a los esquemas que hay en disco y puede borrar columnas o tablas que solo existen en otra rama. Solo se arranca desde un worktree si el cambio toca esquemas de Strapi, con una copia de la base de datos y preguntando antes.
  2. Next, desde el worktree de la tarea, con su propia copia del .env (nunca se edita el del checkout principal). Un proceso de Next sirve un solo sitio; los valores salen de sites[].envFile.
  3. Medir, no mirar a ojo: etiquetas, estilos calculados y tamaños, en local y en PRE (environments.pre) con el mismo tamaño de pantalla, y también en móvil si puede cambiar el layout. Que el contenido del CMS sea distinto es normal; que cambien los estilos, no.
  4. Explicarte cómo comprobarlo: URLs locales, URL del admin de Strapi y campo que hay que activar, y resultado esperado.
  5. Limpiar los servidores y pestañas que se hayan abierto.

Limpieza de worktrees

Cada worktree es un checkout completo: cientos de MB más node_modules. Cuando el MR de una tarea está mergeado en develop y confirmas que la tarea ha terminado, se borra con /hanzo-web:clean-worktrees.

Solo se borra si git status --short está vacío y todos sus commits están en origin/<git.develop>. El trabajo sin commitear nunca se descarta sin un sí explícito. La limpieza diaria opcional con launchd (worktrees.dailyCleanup) hace lo mismo de forma automática.

Texto original del plugin (en inglés)

Así están en context/core.md: son las instrucciones que recibe el agente. Si alguna vez no coinciden con lo de arriba, manda este texto.

  • These rules apply to every Hanzo web project set up with /hanzo-web:init.
  • They work in Claude Code and in Cursor; in Cursor, skills and agents are called without the hanzo-web: prefix (e.g. /release, /code-reviewer), and CLAUDE.local.md is not loaded automatically, so read it from the main checkout at the start of a task.
  • Project-specific facts (architecture, sites, content types, URLs) live in the main checkout's CLAUDE.local.md; where it contradicts these rules, CLAUDE.local.md wins.

Agents and skills

Agent (hanzo-web:…) When
architect Any non-trivial task, before coding: verbatim acceptance criteria, open questions, plan, blast radius (read-only)
usage-finder Before changing anything shared; to find CMS pages and URLs to preview (read-only, fast)
code-reviewer Always, once the code is final and before proposing the MR (read-only)
qa-parity Any change that renders differently: measured checks locally and vs PRE, plus "how to check it yourself"
strapi-cms, nextjs-frontend, scss-styles, unit-tests Parallel or isolated chunks of CMS, front, style or test work
perf-seo-a11y Core Web Vitals, SEO tags/sitemaps, accessibility, audits
build-devops CI, Docker, build/deploy scripts, failing pipelines
Skill Use for
/hanzo-web:jira-task A Jira key or link to implement: full flow from Jira to MR proposal
/hanzo-web:preview-local "Levanta el local / ¿cómo lo compruebo?": Strapi + Next, pages, PRE comparison
/hanzo-web:ci-status Pipeline/job status of a branch or MR and why a job failed
/hanzo-web:release Cut release/vDD_MM_YY and its two MRs
/hanzo-web:clean-worktrees Remove merged worktrees safely
/hanzo-web:init Set up or refresh a project's Claude context
  • Single-module tasks are faster in the main session.
  • The agents that pay off are the read-only ones with a clean context:
    • architect up front
    • usage-finder for impact
    • code-reviewer and qa-parity at the end
  • Brief an agent with the worktree path, the Jira acceptance criteria and the user's decisions; give the reviewer the code, not your conclusions.

Session start

  • At the start of every session, before doing any work, ask the user whether a Jira task from the config.jira.key board should be referenced.
  • If they give one, use its key in branch names and in the MR title ([KEY-123] <Title>), and read the issue with the Atlassian tools.
  • Commit messages do not carry the key.

Git workflow

  • Worktrees: each task in config.worktrees.dir/<slug> on feature/<KEY-123>-<slug> (bugs: fix/…), cut from a fresh origin/<config.git.develop>. Never switch the main checkout's branch for a task. Symlink the Next app's node_modules from the main checkout; copy its .env only if you will run Next.
  • Push only to config.gitlab.remote (config.gitlab.host). Never push to another remote without asking.
  • Short subjects: commit subjects and MR titles ideally under ~50 characters; details go in the body / Changes list.
  • Before deleting or replacing anything that looks generated or odd (a committed sitemap, a stale file), check git log --follow -- <file> for why it exists.

Code quality (CodeClimate) — required for every feature and bugfix

  • CI runs code_quality + quality_gate (sysadmin/gitlab-ci-ymls → shared/quality-gate.yml, rules in hanzo/quality-gate).
  • The MR fails when issues new compared with develop are more than 0 major or more than 2 minor.
  • Checks: argument-count > 4, method-lines > 25, file-lines > 250, cognitive complexity > 5, nesting > 4, return statements > 4, complex logic > 4, duplication (JavaScript), CodeClimate's default ESLint rules on .js, and TODO/FIXME/HACK/XXX/BUG comments.
  • Test folders, *.d.ts and *.min.js are excluded.
  1. Run it once the code is final and lint/tests pass: node <plugin scripts>/quality-gate-local.mjs <worktree-path> (the scripts path is printed above). It reads config.codeclimate.srcDirs and compares HEAD plus uncommitted changes with the merge-base with origin/<config.git.develop>. --all lists every issue; --base <ref> changes the base.
  2. Fix the new issues — aim for 0, not just ≤ 2 — by splitting components/functions, extracting helpers, reducing nesting and duplication. Don't refactor unrelated code. Design small files from the start.
  3. Each new .js file gives 2 minor "rule not found" issues in CI (CodeClimate's ESLint can't load the project's plugins): add new .js files to the Next app's .eslintignore or prefer .ts/.tsx.
  4. Report the gate line when wrapping up (e.g. "CodeClimate: 0 major / 1 minor new → PASS") and any remaining issues. Run it before any MR, even for changes with no JS. The CI quality_gate job is the final word.

House rules for changes

  • New CMS fields that change behaviour default to today's behaviour (boolean false), so existing content renders byte-for-byte the same.
  • Performance, SEO and refactor work must not change how the site looks or works; plan a parity check against PRE.
  • Static export projects: no API routes, getServerSideProps or middleware; guard window/document.
  • Shared components and global SCSS classes: list every user (blast radius) before changing them.
  • Never commit .env, Strapi .tmp/data.db, public/uploads, build output or Claude files (CLAUDE.local.md, .claude/).

Merge requests

  • When a task is complete and the CodeClimate check has passed, ask the user whether to open an MR against config.git.develop.
  • Never create it without their confirmation.
  • The GitLab MCP can't edit an MR after creating it, so get title, target and description right first.
  • Give the description to the user as a Markdown block in the chat (not as a file) unless they ask otherwise.

The description is always in English, in Markdown:

md
## [KEY-123] <Title: one-line summary of the task's goal>

<Link to the Jira issue>

### Changes
- **<Change 1>**: brief explanation of what was changed and why.
- **<Change 2>**: brief explanation of what was changed and why.

With a Jira task the key prefixes the title ([KEY-123] <Title>) in the MR title field and in the ## heading; without one, omit the prefix and the link.

CI status (GitLab)

  • To check pipelines and jobs use, in this order:
    • the GitLab MCP if the session has it (get_merge_request_pipelines, get_pipeline_jobs)
    • the glab CLI (glab ci status, glab ci view, glab ci trace <job>)
    • or the REST API with a token from the environment (GITLAB_TOKEN)
  • Never print, store or commit tokens and never ask the user to paste one in the chat.
  • Read-only by default: ask before retrying, cancelling or running pipelines or manual jobs.
  • /hanzo-web:ci-status has the full procedure.

Releases

  • Use /hanzo-web:release.
  • In short: release/vDD_MM_YY (today's date) cut from origin/<config.git.develop> in a worktree; the only change is config.release.versionConst in config.release.versionFile set to 'DD-MM-YY' (commit Bump version to vDD_MM_YY); two MRs (into config.git.production and config.git.develop) titled Release vDD_MM_YY whose Changes list is the titles of the MRs merged since the last release; "Squash commits" and "Delete source branch" unticked on both.
  • A forgotten MR after merging: never rewrite config.git.production/config.git.develop; fast-forward the release branch and bump to DD-MM-YY+1.

Local visual testing

Use /hanzo-web:preview-local. Key rules:

  1. Strapi always from the main checkout. On start-up Strapi syncs the DB to the schemas on disk and can drop columns/tables that only exist on another branch. Only start it from a worktree when the change touches Strapi schemas, with a copy of the DB, and ask first.
  2. Next from the feature's worktree, with its own copy of .env (never edit the main checkout's .env). One Next process serves one site; take the env values from config.sites[].envFile.
  3. Measure, don't eyeball: tag names, computed styles and bounding boxes, locally and on PRE (config.environments.pre) at the same viewport; mobile too when layout can change. CMS content differences are expected; style differences are not.
  4. Tell the user how to check it: local URLs, Strapi admin URL and the field to toggle, expected result.
  5. Clean up the servers and tabs you started.

Worktree cleanup

  • Each worktree is a full checkout (hundreds of MB plus node_modules).
  • Once a task's MR is merged into develop and the user confirms the task is finished, remove the worktree with /hanzo-web:clean-worktrees: only when git status --short is empty and every commit is in origin/<config.git.develop>.
  • Never discard uncommitted work without an explicit yes.
  • The optional daily launchd job (config.worktrees.dailyCleanup) does the same automatically.