Inicio / Artículos / Chuleta de Claude Code: CLAUDE.md, hooks, skills, MCP y modos

Chuleta de Claude Code: CLAUDE.md, hooks, skills, MCP y modos

Referencia rápida de Claude Code: CLAUDE.md, prompts, reglas, hooks, skills, MCP, subagentes, worktrees, modos de permisos, comandos clave y prompts que vale la pena guardar.

1905 palabras

Claude Code es el asistente de programación agéntico de Anthropic. Escribir fragmentos de código no es lo único que hace. Puede:

  • Entender una base de código existente
  • Leer y editar varios archivos a la vez
  • Ejecutar comandos en la terminal
  • Escribir tests y ejecutarlos
  • Localizar errores
  • Refactorizar código
  • Encargarse de operaciones de Git
  • Llamar a herramientas MCP y disparar hooks
  • Pasar trabajo a subagentes
  • Construir funcionalidades a partir de instrucciones en lenguaje corriente

El modelo mental básico

You
 ↓
Natural-language prompt
 ↓
Claude Code
 ↓
Understand codebase
 ↓
Plan
 ↓
Read files
 ↓
Modify code
 ↓
Run tests / commands
 ↓
Review result
 ↓
Iterate

Hay tres términos que se confunden con facilidad. Claude es el modelo de IA y asistente de Anthropic: sigue lenguaje natural, razona sobre la información, maneja código y documentos y asume muchas tareas de IA. Claude Code es la herramienta de programación agéntica que permite a Claude trabajar con una base de código, archivos, comandos de terminal, tests, Git y herramientas externas para completar tareas de desarrollo. Un agente de IA es cualquier sistema capaz de entender un objetivo, planificar pasos, usar herramientas, actuar, comprobar los resultados e iterar hasta terminar la tarea. Vale la pena memorizar un diagrama:

                         🤖 CLAUDE
                            │
                            ↓
                     CLAUDE CODE
                            │
                     ┌──────┴──────┐
                     ↓             ↓
                   PROMPT        RULES
                "Do this"      "Follow this"
                     │             │
                     └──────┬──────┘
                            ↓
                          AGENT
                            │
              ┌─────────────┼─────────────┐
              ↓             ↓             ↓
           Commands       Skills         Tools
              │             │             │
              ↓             ↓             ↓
          /help etc.    Reusable        Terminal
                        capability      Git
                                        Files
                                         │
                              ┌──────────┴──────────┐
                              ↓                     ↓
                             MCP                  HOOKS
                              ↓                     ↓
                       External tools        Automatic actions
                              │
                              ↓
                         SUB-AGENTS
                              ↓
                       Delegated tasks
                              │
                              ↓
                         WORKTREES
                              ↓
                       Isolated Git work

Comandos

Claude Code trae un conjunto de comandos slash integrados, y lo mejor es aprenderlos desde su propia lista de comandos.

CLAUDE.md

CLAUDE.md es un archivo de instrucciones del proyecto. Da a Claude Code contexto específico del proyecto, comandos, notas de arquitectura y pautas de código, así que piensa en él como el manual del proyecto para Claude.

CLAUDE.md

Project:
Android banking application

Architecture:
Clean Architecture + MVVM

Modules:
app
core
network
database
feature-login

Commands:
./gradlew test
./gradlew lint

Rules:
- Use Kotlin
- Use Coroutines
- Use existing centralized utilities
- Add tests for new functionality
- Don't duplicate networking code

Es útil porque las indicaciones persisten, de modo que los desarrolladores no tienen que volver a explicar una y otra vez la arquitectura, los comandos, las convenciones y las reglas.

Prompts

Un prompt es la instrucción en lenguaje natural que le dice a la IA cuál es la tarea o el objetivo. Un buen prompt agéntico investiga antes de cambiar nada:

First investigate the existing authentication flow.

Do not modify anything yet.

Explain:
- frontend flow
- backend flow
- API involved
- relevant files
- likely problem

Then propose a fix.

After approval, implement it, test it,
review the diff, and commit the changes.

Reglas

Las reglas son restricciones o pautas que determinan cómo el agente lleva a cabo una tarea. Los proyectos más grandes pueden dividir las instrucciones por tema dentro de .claude/rules/:

.claude/rules/
├── testing.md
├── security.md
├── frontend.md
├── backend.md
└── android.md

Un archivo de reglas podría decir:

Rules:

- Use Kotlin.
- Follow MVVM.
- Do not create duplicate utility functions.
- Reuse existing components.
- Write tests for new functionality.
- Do not modify unrelated modules.
- Never expose secrets.
- Run lint before committing.

Hooks

Un hook es una acción automática que se dispara con un evento concreto, por ejemplo ejecutar un comando o una validación después de una acción determinada del agente. Los hooks aportan automatización, coherencia y barreras de seguridad a lo que hace el agente. Cada vez que ocurre algo, se ejecuta una acción sola. Por ejemplo:

Before build
     ↓
   HOOK
     ↓
Check:
- formatting
- lint
- dependencies
- tests
     ↓
Build

En un proyecto real, los hooks podrían estar en una carpeta como esta:

.claude/
└── hooks/
      │
      ├── lint
      ├── test
      ├── dependency-check
      ├── security-check
      └── pre-build

Skills

Las skills son flujos de trabajo o instrucciones especializados y reutilizables, guardados por tema:

.claude/skills/

├── android-development/
├── compose-ui/
├── kotlin-testing/
├── api-integration/
└── code-review/

Cada skill es un documento breve, como este:

Android Development Skill

When modifying Android code:

- Use Kotlin
- Follow MVVM
- Use Coroutines
- Use StateFlow
- Follow existing architecture
- Add tests
- Run lint
- Avoid duplicate utilities

MCP

MCP, el Model Context Protocol, es un protocolo estandarizado que permite a las aplicaciones de IA conectarse con herramientas y fuentes de datos externas.

Subagentes

Los subagentes son agentes especializados a los que el agente principal puede delegar partes de una tarea más grande, para repartir el trabajo complejo:

                 Main Agent
                     │
        ┌────────────┼────────────┐
        ↓            ↓            ↓
    Sub-agent    Sub-agent    Sub-agent
     Backend      Security       Tests
        │            │            │
        └────────────┼────────────┘
                     ↓
                Main Agent
                     ↓
                Final result

Git worktrees

Un worktree de Git te da varios directorios de trabajo ligados a ramas distintas, para que varias tareas avancen de forma independiente:

                 Git Repository
                       │
          ┌────────────┼────────────┐
          ↓            ↓            ↓
       Worktree A   Worktree B   Worktree C
       Feature A    Feature B    Bug Fix

Esto ayuda con los agentes de IA, porque dos de ellos pueden trabajar en tareas separadas sin chocar constantemente en un mismo directorio de trabajo. Un worktree es un espacio aislado para el trabajo con Git.

Modos de permisos

Claude Code tiene modos de permisos que controlan cuánta libertad tiene Claude al usar herramientas:

┌──────────────────────────────────────────────────────────┐
│                 CLAUDE CODE MODES                       │
├──────────────┬───────────────────────────────────────────┤
│ 🖐 MANUAL    │ Claude asks for approval before actions   │
│              │ or changes. You stay in control.         │
├──────────────┼───────────────────────────────────────────┤
│ ✏️ EDIT      │ Claude can edit the selected text/file    │
│              │ or make the requested code changes.      │
├──────────────┼───────────────────────────────────────────┤
│ 📋 PLAN      │ Claude explores the codebase, analyzes    │
│              │ the problem and presents a plan BEFORE    │
│              │ making edits.                             │
├──────────────┼───────────────────────────────────────────┤
│ ⚡ AUTO      │ Claude can take actions automatically     │
│              │ and automatically check/continue through  │
│              │ the task.                                 │
└──────────────┴───────────────────────────────────────────┘

Qué modo elegir depende de cuánta supervisión necesite la tarea.

README.md frente a CLAUDE.md

README.md documenta el proyecto para personas, mientras que CLAUDE.md contiene instrucciones y contexto pensados específicamente para Claude Code.

/clear frente a /compact

/clear borra el contexto de la conversación actual. /compact lo resume y lo comprime, para que el trabajo siga con menos contexto.

@file

Escribir @file hace referencia a un archivo concreto y pasa su contenido a Claude como contexto para la tarea.

El atajo #

El prefijo # es una forma rápida de añadir instrucciones o memoria propias del proyecto.

Por qué importan los tests en la programación agéntica

El agente hace cambios reales en una base de código. Los tests le dicen si esos cambios funcionan y le ayudan a detectar y corregir fallos.

Chuleta final

Claude
→ Anthropic's AI model/assistant

Claude Code
→ Agentic coding tool

Agent
→ AI that can reason + use tools + take actions

Prompt
→ What I ask it to do

Rules
→ Constraints it must follow

CLAUDE.md
→ Project handbook/instructions

Commands
→ Special controls like /help, /init, /clear, /compact

Hooks
→ Automatic actions triggered by events

Skills
→ Reusable specialized capabilities/instructions

Templates
→ Predefined reusable structure

MCP
→ Connect Claude to external tools/data

Sub-agents
→ Specialized agents delegated work

Worktrees
→ Separate Git workspaces

README.md
→ Human project documentation

CLAUDE.local.md
→ Local/personal project instructions
  where that convention is used

audit_summary.md
→ Usually custom audit report

clone.md
→ Usually custom setup/clone documentation

push_to_github.sh
→ Usually custom Git automation script

push_now.md
→ Usually custom push checklist

Prompts genéricos que conviene guardar

Un prompt inicial general para una aplicación desconocida:

I am new to this application.

Do not modify anything.

Give me a high-level overview of the application.

Explain:
- What the application does
- Main features
- Main technologies
- Project structure
- Modules
- Important packages
- Architecture
- Main entry points
- External services
- Database
- APIs
- Testing
- Build and deployment process

Start with a simple explanation for a developer who is new to this project.

Para entender la arquitectura:

Analyze the architecture of this application.

Do not modify anything.

Explain:

- Architecture pattern
- Modules
- Layers
- Dependency flow
- Data flow
- API layer
- Business layer
- Data layer
- UI layer

Identify the main architectural patterns being used.

Then draw an architecture diagram.

Para encontrar los principales puntos de entrada:

Identify the main entry points of this application.

For each entry point, explain:

- File
- Class/function
- What triggers it
- What it calls next
- Where the request eventually ends

Create a simple flow diagram.

Para que Claude lo pruebe todo:

Analyze the changes made in this task.

Identify all relevant tests.

Run:
- Unit tests
- Integration tests
- UI tests where applicable
- Lint
- Type checks
- Build

If anything fails:
- investigate the root cause
- fix it
- rerun the failing checks

At the end, give me a summary of:
PASS / FAIL / NOT RUN

Playwright con MCP

Para automatizar el navegador, pide a Claude que use un servidor MCP de Playwright ya configurado.

Use the Playwright MCP server.

Open the application in the browser.

Visit the login page.

Take a screenshot.

Then:
1. Enter the test credentials.
2. Click Login.
3. Verify that the dashboard appears.
4. Navigate to [PAGE].
5. Click [LINK/BUTTON].
6. Take screenshots at the important steps.
7. Report any errors or unexpected behavior.

Do not modify the application.

Diez prompts que vale la pena aprenderse de memoria:

① OVERVIEW
"Give me an overview of this application."

② STRUCTURE
"Explain the project structure and important files."

③ FLOW
"Trace a user's query from frontend to backend and draw a diagram."

④ DOCUMENT
"Trace how a document is processed from upload to final answer."

⑤ RUN
"How do I run, test, lint and build this application?"

⑥ PLAN
"Analyze the existing implementation and create a plan before editing."

⑦ IMPLEMENT
"Implement this feature, reuse existing code, test it and review the diff."

⑧ DEBUG
"Reproduce this error, find the root cause, fix it and add a regression test."

⑨ UI
"Use Playwright MCP to test the user flow and take screenshots."

⑩ GIT
"Review the diff, run checks, resolve conflicts if needed, and commit."