Skip to content
Maintenance Robot Architect logo

Maintenance Robot Architect

Especialista en la actualización del sistema de auto-migración "Maintenance Robot" en orchestrator_service/main.py.

SKILL.md

Full skill instructions

Maintenance Robot Architect

Este Skill instruye al agente sobre cómo modificar, extender y mantener el sistema de inicialización de base de datos automatizado, conocido como "Maintenance Robot". Dicho sistema reside en la lista migration_steps dentro de orchestrator_service/​main.py.

Propósito

Asegurar que CADA NUEVO DESPLIEGUE en un entorno limpio (Zero-Config / Self-Hosted) nazca completamente funcional, con:

  1. Todas las tablas necesarias creadas.
  2. Datos semilla ("seed data") críticos insertados.
  3. Columnas nuevas agregadas a tablas existentes.

Esto elimina la necesidad de ejecutar scripts SQL manuales o depender de carpetas db/​init que a veces no se montan correctamente en orquestadores como EasyPanel.

Reglas de Oro (Protocolo Omega)

  1. Idempotencia Absoluta:

    • Todo create table debe ser CREATE TABLE IF NOT EXISTS.
    • Toda inserción de datos semilla debe tener ON CONFLICT DO NOTHING (o DO UPDATE si es configuración mutable).
    • Toda alteración de columna debe usar bloques DO $$ ... EXCEPTION ... END $$ para capturar errores si la columna ya existe.
  2. Atomicidad por Paso:

    • Cada elemento de la lista migration_steps se ejecuta como una transacción individual implícita.
    • Si un paso falla, se loguea el error pero el sistema intenta continuar (Soft Fail), a menos que sea una tabla crítica que impida el arranque.
  3. No Borrar Pasos Antiguos:

    • La historia de migración se mantiene secuencial. Agrega nuevos pasos al final de la lista.
    • Solo modifica pasos existentes si detectas un error grave de sintaxis que rompe el arranque.

Guía de Implementación

1. Ubicación

El código vive en orchestrator_service/​main.py. Busca la variable:

migration_steps = [
    # ... pasos previos ...
]

2. Formato de Nuevo Paso

Para agregar una nueva tabla o semilla, añade un string triple-comilla al final de la lista:

    # N. Nombre Descriptivo (vX.X Update)
    """
    -- Tu SQL Aquí
    CREATE TABLE IF NOT EXISTS nueva_tabla (...);
    
    INSERT INTO nueva_tabla (...) VALUES (...) ON CONFLICT DO NOTHING;
    """

3. Manejo de Seeds Complejos

Si necesitas lógica condicional (ej: "Solo insertar X si existe Y"), usa bloques PL/​pgSQL anónimos:

DO $$
DECLARE
    parent_id INT;
BEGIN
    SELECT id INTO parent_id FROM parent_table WHERE name = 'target';
    
    IF parent_id IS NOT NULL THEN
        INSERT INTO child_table (parent_id, ...) VALUES (parent_id, ...);
    END IF;
END $$;

Casos de Uso Comunes

  • Nuevas Credenciales: Si el sistema ahora soporta un nuevo proveedor (ej: TikTok), debes agregar el INSERT en oauth_providers y sus tipos en credential_types aquí.
  • Nuevas Columnas: Si el modelo SQLAlchemy agrega un campo, agrega el ALTER TABLE aquí para que las BD existentes se actualicen al reiniciar.
  • Configuración Global: Si cambias políticas globales (ej: Prompt del Sistema por defecto), actualiza el paso de UPDATE tenants SET system_prompt_template = ....

More Other skills

Delegate independent tasks to specialized agents working concurrently with isolated context.

295.4K 206.3K
View

Applies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand colors or style guidelines, visual formatting, or company design standards apply.

179.7K 100.1K
View

Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with colors/fonts that you can apply to any artifact that has been creating, or can generate a new theme on-the-fly.

179.7K 89.5K
View

A set of resources to help me write all kinds of internal communications, using the formats that my company likes to use. Claude should use this skill whenever asked to write some sort of internal communications (status reports, leadership updates, 3P updates, company newsletters, FAQs, incident reports, project updates, etc.).

179.7K 76.1K
View

Fundamental design principles for writing maintainable, testable Python code.

40.2K 21.9K
View

Modern responsive layouts using container queries, fluid typography, CSS Grid, and mobile-first strategies.

40.2K 20K
View

Generate Playwright tests from scenarios using interactive browser exploration and validation.

39.7K 18.2K
View

Modern React state management with Redux Toolkit, Zustand, Jotai, and React Query for every state category.

40.2K 14.7K
View

GDPR-compliant data handling with consent management, data subject rights, and privacy controls.

40.2K 14.3K
View

Python error handling patterns including input validation, exception hierarchies, and partial failure handling. Use when implementing validation logic, designing exception strategies, handling batch processing failures, or building robust APIs.

40.2K 13.5K
View

Detailed multi-file refactor planning with safety checks and rollback guidance.

39.7K 13K
View