Productividad del desarrollador

Context Engineering

Addy OsmaniMITIdioma del Skill: Inglés
Licencia verificadaSin scriptsRiesgo bajo
DemostraciónEjecución real · claude-sonnet-5-5 · octubre de 2026
My AI coding agent keeps ignoring our conventions on a Next.js 15 + TypeScript + Prisma + Tailwind project (fictional example): it uses default exports, invents helper functions that already exist in src/lib, and edits the Prisma schema without asking. I am about to start the "checkout" feature (src/checkout/ and src/lib/payments.ts). Please set up the agent's context properly: write the rules file in the current folder and a short task context block I can paste at the start of the session.
Skill: context-engineering

I wrote CLAUDE.md in the current folder. Since the project is fictional, I couldn't check it against real files, so a few parts are guesses (listed below).

The rules file covers your three problems directly:

  • Default exports: named exports only, with a short exception list for the files Next.js requires to be default.
  • Invented helpers: the agent must search src/lib/ before writing any helper. If it thinks one is missing, it has to say what it searched and ask first.
  • Prisma schema: it may not edit schema.prisma or run migrate or db push without approval. It must stop and describe the change instead.

It also tells the agent to ask rather than guess when requirements conflict or are missing.

Task context block to paste at the session start

TASK: Implement the "checkout" feature.

SCOPE (only touch these):
- src/checkout/        (new feature code: UI, server actions, types)
- src/lib/payments.ts  (payment logic)

READ FIRST, before writing anything:
- src/lib/payments.ts and `ls src/lib` (reuse existing helpers; list what you found)
- One existing feature folder in src/ as the pattern to follow: <PATH, e.g. src/cart/>
- The relevant Prisma models (read-only): <MODEL NAMES, e.g. Order, OrderItem, Payment>

CONSTRAINTS:
- Follow CLAUDE.md: named exports, reuse src/lib, no new deps.
- Do NOT modify prisma/schema.prisma. If checkout needs a schema change, stop and propose it.
- Never log or store raw card data; <PAYMENT PROVIDER, e.g. Stripe> handles it.

OPEN QUESTIONS (ask me, don't guess): <e.g. guest checkout? tax/shipping rules? failure and retry behavior?>

FIRST STEP: reply with a short plan (files to create or change, existing helpers you'll reuse), then wait for my go-ahead.

What you need to fill in

  • Commands: I assumed standard npm scripts. Check them against your package.json.
  • Pattern example: The example at the bottom is a placeholder. Swap in a real file from your repo, because one concrete example does more than any rule.
  • Block placeholders: Fill the <...> spots in the pasted block (pattern folder, Prisma models, payment provider, open questions).
  • Session length: Start a fresh session when checkout is done. If the session runs long, compact the history around 75% of the window and keep the task block and constraints intact.

Test run on a fictional Next.js project: the model wrote a CLAUDE.md in a temporary folder and a task context block, and said which parts were guesses (commands, the pattern example, placeholders). It could not check the rules against real project files.

Qué hace

Considera el contexto como la palanca más importante para la calidad del resultado del agente. Establece una jerarquía de cinco niveles, de lo más persistente a lo más transitorio (archivo de reglas, especificación y arquitectura, archivos de código fuente relevantes, salida de error e historial de conversación), y muestra cómo escribir un archivo de reglas (CLAUDE.md, .cursorrules, AGENTS.md y equivalentes) con el stack, los comandos, las convenciones, los límites y un ejemplo de patrón. Cubre cargar solo la sección relevante de la especificación, leer el archivo y un ejemplo similar antes de editar, tratar como datos el texto que parece una instrucción en archivos externos, devolver solo el error que falla, límites de sesión que permiten reiniciar, tres estrategias de empaquetado (volcado sin filtro, inclusión selectiva y resumen jerárquico) y reglas de presupuesto: empezar a recortar en torno al 75 %, comprimir antes de descartar y colocar al final el material crítico para la tarea. También indica que se deben hacer visibles los conflictos y los requisitos que faltan en lugar de adivinar.

Resultado

Un archivo de reglas para tu proyecto, un breve bloque de contexto de la tarea para pegar al inicio de una sesión y una lista de lo que aún debes completar.

Ideal para

Preparar un proyecto para el trabajo asistido por IA y corregir agentes que ignoran las convenciones, inventan funciones auxiliares o pierden el foco en sesiones largas.

Notas y riesgos

Riesgo bajo: solo instrucciones, sin scripts. Escribe un archivo de reglas como CLAUDE.md en tu proyecto y menciona servidores MCP que podrías añadir; no instala ninguno. Un archivo de reglas cambia el comportamiento de tu agente, así que lee lo que escribió. Se probó una vez en un proyecto ficticio de Next.js: escribió un CLAUDE.md y un bloque de tarea y marcó las partes que tuvo que suponer (los comandos, el ejemplo de patrón), ya que no pudo comprobarlas con archivos reales. Por Addy Osmani, MIT.

SKILL.md original2 archivos en este paquete