claude-agent-framework 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (111) hide show
  1. package/README.md +128 -0
  2. package/bin/claude-framework +3 -0
  3. package/framework/agents/design-lead.md +240 -0
  4. package/framework/agents/product-owner.md +179 -0
  5. package/framework/agents/tech-lead.md +226 -0
  6. package/framework/commands/ayuda.md +127 -0
  7. package/framework/commands/a/303/261adir.md +98 -0
  8. package/framework/commands/backup.md +397 -0
  9. package/framework/commands/cambiar.md +110 -0
  10. package/framework/commands/cloud.md +457 -0
  11. package/framework/commands/code.md +142 -0
  12. package/framework/commands/debug.md +334 -0
  13. package/framework/commands/deploy.md +383 -0
  14. package/framework/commands/deshacer.md +120 -0
  15. package/framework/commands/estado.md +218 -0
  16. package/framework/commands/explica.md +227 -0
  17. package/framework/commands/feature.md +120 -0
  18. package/framework/commands/git.md +427 -0
  19. package/framework/commands/historial.md +202 -0
  20. package/framework/commands/learn.md +408 -0
  21. package/framework/commands/movil.md +245 -0
  22. package/framework/commands/nuevo.md +118 -0
  23. package/framework/commands/plan.md +134 -0
  24. package/framework/commands/prd.md +113 -0
  25. package/framework/commands/probar.md +148 -0
  26. package/framework/commands/revisar.md +208 -0
  27. package/framework/commands/seeds.md +230 -0
  28. package/framework/commands/seguridad.md +226 -0
  29. package/framework/commands/tasks.md +157 -0
  30. package/framework/skills/architecture/algorithms.md +970 -0
  31. package/framework/skills/architecture/clean-code.md +1080 -0
  32. package/framework/skills/architecture/design-patterns.md +1984 -0
  33. package/framework/skills/architecture/functional-programming.md +972 -0
  34. package/framework/skills/architecture/solid.md +991 -0
  35. package/framework/skills/cloud/cloud-aws.md +848 -0
  36. package/framework/skills/cloud/cloud-azure.md +931 -0
  37. package/framework/skills/cloud/cloud-gcp.md +848 -0
  38. package/framework/skills/cloud/message-queues.md +1229 -0
  39. package/framework/skills/core/accessibility.md +401 -0
  40. package/framework/skills/core/api.md +474 -0
  41. package/framework/skills/core/authentication.md +306 -0
  42. package/framework/skills/core/authorization.md +388 -0
  43. package/framework/skills/core/background-jobs.md +341 -0
  44. package/framework/skills/core/caching.md +473 -0
  45. package/framework/skills/core/code-review.md +341 -0
  46. package/framework/skills/core/controllers.md +290 -0
  47. package/framework/skills/core/cua.md +285 -0
  48. package/framework/skills/core/documentation.md +472 -0
  49. package/framework/skills/core/file-uploads.md +351 -0
  50. package/framework/skills/core/hotwire-native.md +296 -0
  51. package/framework/skills/core/hotwire.md +278 -0
  52. package/framework/skills/core/i18n.md +334 -0
  53. package/framework/skills/core/imports-exports.md +750 -0
  54. package/framework/skills/core/infrastructure.md +337 -0
  55. package/framework/skills/core/models.md +228 -0
  56. package/framework/skills/core/notifications.md +672 -0
  57. package/framework/skills/core/payments.md +581 -0
  58. package/framework/skills/core/performance.md +361 -0
  59. package/framework/skills/core/rails-scaffold.md +131 -0
  60. package/framework/skills/core/search.md +518 -0
  61. package/framework/skills/core/security.md +565 -0
  62. package/framework/skills/core/seeds.md +307 -0
  63. package/framework/skills/core/seo.md +542 -0
  64. package/framework/skills/core/testing.md +393 -0
  65. package/framework/skills/core/views.md +260 -0
  66. package/framework/skills/core/websockets.md +564 -0
  67. package/framework/skills/data/advanced-sql.md +1204 -0
  68. package/framework/skills/data/nosql.md +1141 -0
  69. package/framework/skills/devops/containers-advanced.md +1237 -0
  70. package/framework/skills/devops/debugging.md +834 -0
  71. package/framework/skills/devops/git-workflow.md +752 -0
  72. package/framework/skills/devops/networking.md +932 -0
  73. package/framework/skills/devops/shell-scripting.md +1132 -0
  74. package/framework/sub-agents/architecture-patterns-agent.md +1450 -0
  75. package/framework/sub-agents/cloud-agent.md +677 -0
  76. package/framework/sub-agents/data.md +504 -0
  77. package/framework/sub-agents/debugging-agent.md +554 -0
  78. package/framework/sub-agents/devops.md +483 -0
  79. package/framework/sub-agents/docs.md +176 -0
  80. package/framework/sub-agents/frontend-dev.md +349 -0
  81. package/framework/sub-agents/git-workflow-agent.md +697 -0
  82. package/framework/sub-agents/integrations.md +630 -0
  83. package/framework/sub-agents/native-dev.md +434 -0
  84. package/framework/sub-agents/qa.md +138 -0
  85. package/framework/sub-agents/rails-dev.md +375 -0
  86. package/framework/sub-agents/security.md +526 -0
  87. package/framework/sub-agents/ui.md +437 -0
  88. package/framework/sub-agents/ux.md +284 -0
  89. package/framework/templates/api-spec.md +500 -0
  90. package/framework/templates/component-spec.md +248 -0
  91. package/framework/templates/feature.json +13 -0
  92. package/framework/templates/model-spec.md +318 -0
  93. package/framework/templates/prd-template.md +80 -0
  94. package/framework/templates/task-plan.md +122 -0
  95. package/framework/templates/task-user-story.md +52 -0
  96. package/framework/templates/technical-spec.md +260 -0
  97. package/framework/templates/user-story.md +95 -0
  98. package/package.json +42 -0
  99. package/project-templates/CLAUDE.md +42 -0
  100. package/project-templates/contexts/architecture.md +25 -0
  101. package/project-templates/contexts/conventions.md +46 -0
  102. package/project-templates/contexts/design-system.md +47 -0
  103. package/project-templates/contexts/requirements.md +38 -0
  104. package/project-templates/contexts/stack.md +30 -0
  105. package/project-templates/history/active/models.md +11 -0
  106. package/project-templates/history/changelog.md +15 -0
  107. package/project-templates/workspace/.gitkeep +0 -0
  108. package/src/cli.js +52 -0
  109. package/src/init.js +104 -0
  110. package/src/status.js +75 -0
  111. package/src/update.js +88 -0
@@ -0,0 +1,334 @@
1
+ # Comando: /debug
2
+
3
+ Analiza errores y ayuda a depurar problemas en la aplicación.
4
+
5
+ ## Uso
6
+
7
+ ```
8
+ /debug [descripción del error | "logs" | "performance"]
9
+ ```
10
+
11
+ ## Parámetros
12
+
13
+ - Sin argumentos: pregunta qué tipo de problema hay
14
+ - `descripción`: analiza el stack trace o error específico
15
+ - `logs`: revisa logs recientes e identifica patrones de error
16
+ - `performance`: ejecuta profiling e identifica problemas de rendimiento
17
+
18
+ ## Flujo de trabajo
19
+
20
+ ### Paso 1: Identificar el tipo de problema
21
+
22
+ Sin argumentos, preguntar:
23
+
24
+ "¿Qué tipo de problema estás experimentando?"
25
+
26
+ Opciones:
27
+ - Un error específico (pega el mensaje o stack trace)
28
+ - La app va lenta
29
+ - Algo no funciona como esperaba
30
+ - Quiero revisar los logs
31
+
32
+ ### Paso 2: Según el tipo de problema
33
+
34
+ #### Para errores específicos
35
+
36
+ 1. **Analizar el stack trace**
37
+ ```bash
38
+ # Extraer información clave
39
+ # - Archivo y línea donde ocurre
40
+ # - Tipo de excepción
41
+ # - Mensaje de error
42
+ # - Contexto (controlador, modelo, vista)
43
+ ```
44
+
45
+ 2. **Identificar la causa probable**
46
+ - Error de sintaxis
47
+ - Nil reference (NoMethodError on nil)
48
+ - Base de datos (ActiveRecord errors)
49
+ - Routing
50
+ - Validación
51
+ - Autorización
52
+
53
+ 3. **Buscar el código relacionado**
54
+ ```bash
55
+ # Leer el archivo mencionado en el stack trace
56
+ # Verificar el contexto alrededor de la línea
57
+ ```
58
+
59
+ 4. **Proponer solución**
60
+ - Explicar qué está pasando en lenguaje simple
61
+ - Mostrar el código problemático
62
+ - Proponer corrección con ejemplo
63
+
64
+ #### Para `/debug logs`
65
+
66
+ 1. **Revisar logs recientes**
67
+ ```bash
68
+ # Ver últimas líneas del log de desarrollo
69
+ tail -100 log/development.log
70
+
71
+ # Buscar errores
72
+ grep -i "error\|exception\|fail" log/development.log | tail -50
73
+
74
+ # Ver requests fallidos
75
+ grep "500\|422\|404" log/development.log | tail -20
76
+ ```
77
+
78
+ 2. **Identificar patrones**
79
+ - Errores repetidos
80
+ - Queries lentas
81
+ - Excepciones no manejadas
82
+ - Problemas de memoria
83
+
84
+ 3. **Generar reporte**
85
+ ```markdown
86
+ ## Análisis de Logs
87
+
88
+ ### Errores encontrados
89
+ | Error | Frecuencia | Última vez |
90
+ |-------|------------|------------|
91
+ | [Error 1] | X veces | [timestamp] |
92
+
93
+ ### Warnings
94
+ - [Warning 1]
95
+
96
+ ### Recomendaciones
97
+ 1. [Acción 1]
98
+ 2. [Acción 2]
99
+ ```
100
+
101
+ #### Para `/debug performance`
102
+
103
+ 1. **Ejecutar análisis**
104
+ ```bash
105
+ # Identificar N+1 queries en desarrollo
106
+ # El bullet gem detecta esto automáticamente
107
+
108
+ # Ver queries lentas
109
+ grep "ms)" log/development.log | sort -t'(' -k2 -rn | head -20
110
+ ```
111
+
112
+ 2. **Analizar código**
113
+ - Buscar `each` sin `includes`
114
+ - Identificar queries en loops
115
+ - Verificar índices en la base de datos
116
+ - Revisar uso de memoria
117
+
118
+ 3. **Generar reporte de rendimiento**
119
+ ```markdown
120
+ ## Análisis de Rendimiento
121
+
122
+ ### N+1 Queries Detectadas
123
+ 1. **[Ubicación]**
124
+ - Problema: [Descripción]
125
+ - Solución: `includes(:asociacion)`
126
+
127
+ ### Queries Lentas
128
+ | Query | Tiempo | Ubicación |
129
+ |-------|--------|-----------|
130
+ | [Query] | Xms | [archivo:línea] |
131
+
132
+ ### Índices Faltantes
133
+ - Tabla `X`, columna `Y`
134
+
135
+ ### Recomendaciones
136
+ 1. [Mejora 1]
137
+ 2. [Mejora 2]
138
+ ```
139
+
140
+ ### Paso 3: Proporcionar solución
141
+
142
+ Para cada problema identificado:
143
+
144
+ 1. **Explicar el problema**
145
+ - Qué está pasando
146
+ - Por qué está pasando
147
+ - Impacto (crítico/medio/bajo)
148
+
149
+ 2. **Mostrar la solución**
150
+ ```ruby
151
+ # ❌ Antes (código problemático)
152
+ [código actual]
153
+
154
+ # ✅ Después (código corregido)
155
+ [código sugerido]
156
+ ```
157
+
158
+ 3. **Ofrecer implementar**
159
+ "¿Quieres que aplique esta corrección?"
160
+
161
+ ## Errores comunes y soluciones
162
+
163
+ ### NoMethodError: undefined method for nil:NilClass
164
+
165
+ ```ruby
166
+ # ❌ Problema
167
+ user.profile.name # user.profile es nil
168
+
169
+ # ✅ Solución 1: Safe navigation
170
+ user.profile&.name
171
+
172
+ # ✅ Solución 2: Verificación
173
+ user.profile.name if user.profile.present?
174
+
175
+ # ✅ Solución 3: Default
176
+ user.profile&.name || "Sin nombre"
177
+ ```
178
+
179
+ ### ActiveRecord::RecordNotFound
180
+
181
+ ```ruby
182
+ # ❌ Problema
183
+ @article = Article.find(params[:id]) # Lanza excepción si no existe
184
+
185
+ # ✅ Solución 1: find_by (retorna nil)
186
+ @article = Article.find_by(id: params[:id])
187
+ return head :not_found unless @article
188
+
189
+ # ✅ Solución 2: Manejo de excepción
190
+ rescue ActiveRecord::RecordNotFound
191
+ redirect_to articles_path, alert: "Artículo no encontrado"
192
+ ```
193
+
194
+ ### ActionController::ParameterMissing
195
+
196
+ ```ruby
197
+ # ❌ Problema
198
+ params.require(:article) # :article no está en params
199
+
200
+ # ✅ Solución
201
+ # Verificar que el formulario envía correctamente
202
+ # o hacer el parámetro opcional
203
+ params.fetch(:article, {})
204
+ ```
205
+
206
+ ### N+1 Query
207
+
208
+ ```ruby
209
+ # ❌ Problema
210
+ Article.all.each do |article|
211
+ puts article.user.name # Una query por cada artículo
212
+ end
213
+
214
+ # ✅ Solución
215
+ Article.includes(:user).each do |article|
216
+ puts article.user.name # Una sola query
217
+ end
218
+ ```
219
+
220
+ ### Rollback en validaciones
221
+
222
+ ```ruby
223
+ # ❌ Problema
224
+ # Transaction rolled back - pero no sabes por qué
225
+
226
+ # ✅ Solución: Ver errores
227
+ article = Article.new(params)
228
+ unless article.save
229
+ puts article.errors.full_messages
230
+ end
231
+
232
+ # O usar save! para ver la excepción
233
+ article.save! # Lanza ActiveRecord::RecordInvalid con detalles
234
+ ```
235
+
236
+ ## Herramientas de debugging
237
+
238
+ ### Rails Console
239
+
240
+ ```ruby
241
+ # Iniciar consola
242
+ bin/rails console
243
+
244
+ # Recargar código
245
+ reload!
246
+
247
+ # Ver SQL generado
248
+ Article.where(published: true).to_sql
249
+
250
+ # Debugear objeto
251
+ article.inspect
252
+ article.attributes
253
+
254
+ # Ver errores de validación
255
+ article.valid?
256
+ article.errors.full_messages
257
+ ```
258
+
259
+ ### Byebug/Debug
260
+
261
+ ```ruby
262
+ # Añadir breakpoint en el código
263
+ debugger # Rails 7+
264
+ byebug # Gem byebug
265
+
266
+ # Comandos en el debugger
267
+ n # next (siguiente línea)
268
+ s # step (entrar en método)
269
+ c # continue
270
+ p variable # print variable
271
+ ```
272
+
273
+ ### Logs mejorados
274
+
275
+ ```ruby
276
+ # En cualquier parte del código
277
+ Rails.logger.debug "Variable: #{variable.inspect}"
278
+ Rails.logger.info "Llegamos aquí"
279
+ Rails.logger.error "Algo salió mal: #{error.message}"
280
+ ```
281
+
282
+ ## Checklist de debugging
283
+
284
+ - [ ] ¿Leí el mensaje de error completo?
285
+ - [ ] ¿Identifiqué el archivo y línea del error?
286
+ - [ ] ¿Revisé el contexto alrededor del error?
287
+ - [ ] ¿Busqué el error en Google/Stack Overflow?
288
+ - [ ] ¿Reproduje el error localmente?
289
+ - [ ] ¿Aislé el problema (comentando código)?
290
+ - [ ] ¿Usé breakpoints para inspeccionar el estado?
291
+ - [ ] ¿Verifiqué los datos de entrada?
292
+ - [ ] ¿Revisé los logs?
293
+ - [ ] ¿Probé la solución con tests?
294
+
295
+ ## Ejemplo de salida
296
+
297
+ ```
298
+ 🔍 Analizando el error...
299
+
300
+ 📍 Ubicación: app/controllers/articles_controller.rb:25
301
+
302
+ 🐛 Error: NoMethodError: undefined method 'name' for nil:NilClass
303
+
304
+ 📋 Contexto:
305
+ El error ocurre cuando intentas acceder a `@article.user.name`
306
+ pero el artículo no tiene un usuario asociado (user_id es nil).
307
+
308
+ 💡 Causa probable:
309
+ - El artículo se creó sin asociar un usuario
310
+ - El usuario fue eliminado pero el artículo permanece
311
+
312
+ 🔧 Solución sugerida:
313
+
314
+ # En app/controllers/articles_controller.rb línea 25
315
+ # Cambiar:
316
+ @article.user.name
317
+
318
+ # Por:
319
+ @article.user&.name || "Usuario desconocido"
320
+
321
+ # O mejor, arreglar el modelo:
322
+ # app/models/article.rb
323
+ validates :user, presence: true
324
+
325
+ ¿Quieres que aplique esta corrección?
326
+ ```
327
+
328
+ ## Notas importantes
329
+
330
+ - No modificar código de producción sin entender el problema
331
+ - Siempre reproducir el error antes de corregir
332
+ - Los tests deben pasar después de la corrección
333
+ - Documentar bugs significativos para evitar repetirlos
334
+ - Explicar en lenguaje simple qué pasó y cómo se resolvió
@@ -0,0 +1,383 @@
1
+ # Comando: /deploy
2
+
3
+ ## Descripción
4
+
5
+ Despliega la aplicación a producción de forma guiada y segura.
6
+
7
+ ## Uso
8
+
9
+ ```
10
+ /deploy [entorno]
11
+ ```
12
+
13
+ ## Parámetros
14
+
15
+ - `entorno` (opcional): "staging" o "production" (default: production)
16
+
17
+ ## Proceso de deploy
18
+
19
+ ### 1. Pre-checks
20
+
21
+ Antes de desplegar, verificar:
22
+
23
+ ```bash
24
+ # Estado del repositorio
25
+ git status
26
+ git log --oneline -5
27
+
28
+ # Tests pasando
29
+ bin/rails test
30
+ # o
31
+ bundle exec rspec
32
+
33
+ # Assets compilan
34
+ bin/rails assets:precompile
35
+
36
+ # Migraciones pendientes
37
+ bin/rails db:migrate:status
38
+ ```
39
+
40
+ ### 2. Checklist pre-deploy
41
+
42
+ - [ ] Todos los tests pasan
43
+ - [ ] No hay cambios sin commitear
44
+ - [ ] La rama está actualizada con main/master
45
+ - [ ] Las migraciones son reversibles
46
+ - [ ] Variables de entorno configuradas
47
+ - [ ] Backup de base de datos realizado
48
+
49
+ ### 3. Opciones de hosting gratuito
50
+
51
+ #### Fly.io (Recomendado)
52
+
53
+ ```bash
54
+ # Instalación
55
+ curl -L https://fly.io/install.sh | sh
56
+
57
+ # Login
58
+ fly auth login
59
+
60
+ # Primera vez: crear app
61
+ fly launch
62
+
63
+ # Deploy
64
+ fly deploy
65
+
66
+ # Ver logs
67
+ fly logs
68
+
69
+ # Consola Rails
70
+ fly ssh console -C "bin/rails console"
71
+
72
+ # Migraciones
73
+ fly ssh console -C "bin/rails db:migrate"
74
+ ```
75
+
76
+ **fly.toml básico:**
77
+ ```toml
78
+ app = "mi-app"
79
+ primary_region = "mad"
80
+
81
+ [build]
82
+ [build.args]
83
+ RUBY_VERSION = "3.3.0"
84
+
85
+ [env]
86
+ RAILS_ENV = "production"
87
+ RAILS_LOG_TO_STDOUT = "true"
88
+
89
+ [http_service]
90
+ internal_port = 3000
91
+ force_https = true
92
+ auto_stop_machines = true
93
+ auto_start_machines = true
94
+ min_machines_running = 0
95
+
96
+ [[services]]
97
+ protocol = "tcp"
98
+ internal_port = 3000
99
+
100
+ [[services.ports]]
101
+ port = 80
102
+ handlers = ["http"]
103
+
104
+ [[services.ports]]
105
+ port = 443
106
+ handlers = ["tls", "http"]
107
+
108
+ [[statics]]
109
+ guest_path = "/rails/public"
110
+ url_prefix = "/"
111
+ ```
112
+
113
+ #### Render.com
114
+
115
+ ```yaml
116
+ # render.yaml
117
+ services:
118
+ - type: web
119
+ name: mi-app
120
+ env: ruby
121
+ buildCommand: bundle install && bin/rails assets:precompile
122
+ startCommand: bin/rails server
123
+ envVars:
124
+ - key: RAILS_MASTER_KEY
125
+ sync: false
126
+ - key: DATABASE_URL
127
+ fromDatabase:
128
+ name: mi-app-db
129
+ property: connectionString
130
+
131
+ databases:
132
+ - name: mi-app-db
133
+ plan: free
134
+ ```
135
+
136
+ #### Railway.app
137
+
138
+ ```bash
139
+ # Instalación CLI
140
+ npm i -g @railway/cli
141
+
142
+ # Login
143
+ railway login
144
+
145
+ # Crear proyecto
146
+ railway init
147
+
148
+ # Deploy
149
+ railway up
150
+
151
+ # Variables de entorno
152
+ railway variables set RAILS_ENV=production
153
+ ```
154
+
155
+ ### 4. Deploy con Kamal (Docker)
156
+
157
+ ```bash
158
+ # Instalación
159
+ gem install kamal
160
+
161
+ # Configurar
162
+ kamal init
163
+
164
+ # Deploy
165
+ kamal deploy
166
+ ```
167
+
168
+ **config/deploy.yml:**
169
+ ```yaml
170
+ service: mi-app
171
+ image: usuario/mi-app
172
+
173
+ servers:
174
+ web:
175
+ - 192.168.0.1
176
+ job:
177
+ hosts:
178
+ - 192.168.0.1
179
+ cmd: bin/jobs
180
+
181
+ registry:
182
+ username: usuario
183
+ password:
184
+ - KAMAL_REGISTRY_PASSWORD
185
+
186
+ env:
187
+ clear:
188
+ RAILS_ENV: production
189
+ secret:
190
+ - RAILS_MASTER_KEY
191
+ - DATABASE_URL
192
+
193
+ accessories:
194
+ db:
195
+ image: sqlite3
196
+ host: 192.168.0.1
197
+ directories:
198
+ - data:/rails/storage
199
+
200
+ traefik:
201
+ options:
202
+ publish:
203
+ - "443:443"
204
+ volume:
205
+ - "/letsencrypt:/letsencrypt"
206
+ ```
207
+
208
+ ### 5. Scripts de deploy
209
+
210
+ ```bash
211
+ #!/bin/bash
212
+ # bin/deploy
213
+
214
+ set -e
215
+
216
+ echo "🚀 Iniciando deploy..."
217
+
218
+ # Pre-checks
219
+ echo "📋 Verificando pre-requisitos..."
220
+
221
+ if ! git diff-index --quiet HEAD --; then
222
+ echo "❌ Hay cambios sin commitear"
223
+ exit 1
224
+ fi
225
+
226
+ echo "🧪 Ejecutando tests..."
227
+ bin/rails test || bundle exec rspec
228
+
229
+ echo "📦 Compilando assets..."
230
+ bin/rails assets:precompile
231
+
232
+ echo "🔄 Desplegando..."
233
+ # Descomentar según plataforma:
234
+ # fly deploy
235
+ # railway up
236
+ # kamal deploy
237
+ # git push heroku main
238
+
239
+ echo "🗃️ Ejecutando migraciones..."
240
+ # fly ssh console -C "bin/rails db:migrate"
241
+ # railway run bin/rails db:migrate
242
+ # kamal app exec 'bin/rails db:migrate'
243
+
244
+ echo "✅ Deploy completado!"
245
+ ```
246
+
247
+ ### 6. Post-deploy checks
248
+
249
+ ```ruby
250
+ # lib/tasks/health.rake
251
+ namespace :health do
252
+ desc "Verificar estado de la aplicación"
253
+ task check: :environment do
254
+ checks = []
255
+
256
+ # Base de datos
257
+ begin
258
+ ActiveRecord::Base.connection.execute("SELECT 1")
259
+ checks << "✅ Base de datos: OK"
260
+ rescue => e
261
+ checks << "❌ Base de datos: #{e.message}"
262
+ end
263
+
264
+ # Cache
265
+ begin
266
+ Rails.cache.write("health_check", "ok", expires_in: 1.minute)
267
+ Rails.cache.read("health_check") == "ok" or raise "Cache read failed"
268
+ checks << "✅ Cache: OK"
269
+ rescue => e
270
+ checks << "❌ Cache: #{e.message}"
271
+ end
272
+
273
+ # Storage
274
+ begin
275
+ ActiveStorage::Blob.service.exist?("health_check_#{Time.now.to_i}")
276
+ checks << "✅ Storage: OK"
277
+ rescue => e
278
+ checks << "⚠️ Storage: #{e.message}"
279
+ end
280
+
281
+ # Jobs
282
+ begin
283
+ SolidQueue::Job.count
284
+ checks << "✅ Jobs: OK"
285
+ rescue => e
286
+ checks << "⚠️ Jobs: #{e.message}"
287
+ end
288
+
289
+ puts checks.join("\n")
290
+ end
291
+ end
292
+ ```
293
+
294
+ ### 7. Rollback
295
+
296
+ ```bash
297
+ # Fly.io
298
+ fly releases
299
+ fly deploy --image registry.fly.io/mi-app:v123
300
+
301
+ # Kamal
302
+ kamal rollback
303
+
304
+ # Railway
305
+ railway rollback
306
+
307
+ # Git-based (Heroku, Render)
308
+ git revert HEAD
309
+ git push
310
+ ```
311
+
312
+ ## Variables de entorno necesarias
313
+
314
+ ```bash
315
+ # Producción mínimo
316
+ RAILS_ENV=production
317
+ RAILS_MASTER_KEY=xxx
318
+ SECRET_KEY_BASE=xxx
319
+ DATABASE_URL=sqlite3:///rails/storage/production.sqlite3
320
+
321
+ # Opcionales
322
+ RAILS_LOG_TO_STDOUT=true
323
+ RAILS_SERVE_STATIC_FILES=true
324
+ WEB_CONCURRENCY=2
325
+ RAILS_MAX_THREADS=5
326
+ ```
327
+
328
+ ## Ejemplo de salida
329
+
330
+ ```
331
+ 🚀 Iniciando proceso de deploy...
332
+
333
+ 📋 Pre-checks:
334
+ ✅ Git: rama main, sin cambios pendientes
335
+ ✅ Tests: 142 tests, 0 failures
336
+ ✅ Assets: compilados correctamente
337
+ ✅ Migraciones: 0 pendientes
338
+
339
+ 🔐 Verificación de seguridad:
340
+ ✅ RAILS_MASTER_KEY configurado
341
+ ✅ Credenciales encriptadas
342
+ ✅ No hay secretos expuestos
343
+
344
+ 📦 Desplegando a Fly.io...
345
+ → Building image...
346
+ → Pushing to registry...
347
+ → Deploying v24...
348
+ → Health check passed
349
+
350
+ 🗃️ Post-deploy:
351
+ → Ejecutando migraciones... OK
352
+ → Verificando salud... OK
353
+
354
+ ✅ Deploy completado exitosamente!
355
+
356
+ 🌐 Tu app está disponible en: https://mi-app.fly.dev
357
+ ```
358
+
359
+ ## Respuesta del agente
360
+
361
+ Al ejecutar `/deploy`, el agente:
362
+
363
+ 1. **Verifica pre-requisitos**
364
+ - Estado de git
365
+ - Tests pasando
366
+ - Assets compilando
367
+
368
+ 2. **Detecta plataforma**
369
+ - Busca fly.toml, render.yaml, etc.
370
+ - Sugiere opciones si no hay configuración
371
+
372
+ 3. **Ejecuta deploy**
373
+ - Usa comandos de la plataforma detectada
374
+ - Muestra progreso en tiempo real
375
+
376
+ 4. **Verifica post-deploy**
377
+ - Health checks
378
+ - Migraciones
379
+ - Logs de errores
380
+
381
+ 5. **Reporta resultado**
382
+ - URL de la aplicación
383
+ - Cualquier warning o error