Loading...
Loading...
Optimizes agent context setup. Use when starting a new session, when agent output quality degrades, when switching between tasks, or when you need to configure rules files and context for a project.
npx skill4agent add addyosmani/agent-skills context-engineering┌─────────────────────────────────────┐
│ 1. Rules Files (CLAUDE.md, etc.) │ ← Always loaded, project-wide
├─────────────────────────────────────┤
│ 2. Spec / Architecture Docs │ ← Loaded per feature/session
├─────────────────────────────────────┤
│ 3. Relevant Source Files │ ← Loaded per task
├─────────────────────────────────────┤
│ 4. Error Output / Test Results │ ← Loaded per iteration
├─────────────────────────────────────┤
│ 5. Conversation History │ ← Accumulates, compacts
└─────────────────────────────────────┘# Project: [Name]
## Tech Stack
- React 18, TypeScript 5, Vite, Tailwind CSS 4
- Node.js 22, Express, PostgreSQL, Prisma
## Commands
- Build: `npm run build`
- Test: `npm test`
- Lint: `npm run lint --fix`
- Dev: `npm run dev`
- Type check: `npx tsc --noEmit`
## Code Conventions
- Functional components with hooks (no class components)
- Named exports (no default exports)
- colocate tests next to source: `Button.tsx` → `Button.test.tsx`
- Use `cn()` utility for conditional classNames
- Error boundaries at route level
## Boundaries
- Never commit .env files or secrets
- Never add dependencies without checking bundle size impact
- Ask before modifying database schema
- Always run tests before committing
## Patterns
[One short example of a well-written component in your style].cursorrules.cursor/rules/*.md.windsurfrules.github/copilot-instructions.mdAGENTS.mdTypeError: Cannot read property 'id' of undefined at UserService.ts:42PROJECT CONTEXT:
- We're building [X] using [tech stack]
- The relevant spec section is: [spec excerpt]
- Key constraints: [list]
- Files involved: [list with brief descriptions]
- Related patterns: [pointer to an example file]
- Known gotchas: [list of things to watch out for]TASK: Add email validation to the registration endpoint
RELEVANT FILES:
- src/routes/auth.ts (the endpoint to modify)
- src/lib/validation.ts (existing validation utilities)
- tests/routes/auth.test.ts (existing tests to extend)
PATTERN TO FOLLOW:
- See how phone validation works in src/lib/validation.ts:45-60
CONSTRAINT:
- Must use the existing ValidationError class, not throw raw errors# Project Map
## Authentication (src/auth/)
Handles registration, login, password reset.
Key files: auth.routes.ts, auth.service.ts, auth.middleware.ts
Pattern: All routes use authMiddleware, errors use AuthError class
## Tasks (src/tasks/)
CRUD for user tasks with real-time updates.
Key files: task.routes.ts, task.service.ts, task.socket.ts
Pattern: Optimistic updates via WebSocket, server reconciliation
## Shared (src/lib/)
Validation, error handling, database utilities.
Key files: validation.ts, errors.ts, db.ts| MCP Server | What It Provides |
|---|---|
| Context7 | Auto-fetches relevant documentation for libraries |
| Chrome DevTools | Live browser state, DOM, console, network |
| PostgreSQL | Direct database schema and query results |
| Filesystem | Project file access and search |
| GitHub | Issue, PR, and repository context |
Spec says: "Use REST for all endpoints"
Existing code has: GraphQL for the user profile queryCONFUSION:
The spec calls for REST endpoints, but the existing codebase uses GraphQL
for user queries (src/graphql/user.ts).
Options:
A) Follow the spec — add REST endpoint, potentially deprecate GraphQL later
B) Follow existing patterns — use GraphQL, update the spec
C) Ask — this seems like an intentional decision I shouldn't override
→ Which approach should I take?MISSING REQUIREMENT:
The spec defines task creation but doesn't specify what happens
when a user creates a task with a duplicate title.
Options:
A) Allow duplicates (simplest)
B) Reject with validation error (strictest)
C) Append a number suffix like "Task (2)" (most user-friendly)
→ Which behavior do you want?PLAN:
1. Add Zod schema for task creation — validates title (required) and description (optional)
2. Wire schema into POST /api/tasks route handler
3. Add test for validation error response
→ Executing unless you redirect.| Anti-Pattern | Problem | Fix |
|---|---|---|
| Context starvation | Agent invents APIs, ignores conventions | Load rules file + relevant source files before each task |
| Context flooding | Agent loses focus when loaded with >5,000 lines of non-task-specific context. More files does not mean better output. | Include only what is relevant to the current task. Aim for <2,000 lines of focused context per task. |
| Stale context | Agent references outdated patterns or deleted code | Start fresh sessions when context drifts |
| Missing examples | Agent invents a new style instead of following yours | Include one example of the pattern to follow |
| Implicit knowledge | Agent doesn't know project-specific rules | Write it down in rules files — if it's not written, it doesn't exist |
| Silent confusion | Agent guesses when it should ask | Surface ambiguity explicitly using the confusion management patterns above |
| Rationalization | Reality |
|---|---|
| "The agent should figure out the conventions" | It can't read your mind. Write a rules file — 10 minutes that saves hours. |
| "I'll just correct it when it goes wrong" | Prevention is cheaper than correction. Upfront context prevents drift. |
| "More context is always better" | Research shows performance degrades with too many instructions. Be selective. |
| "The context window is huge, I'll use it all" | Context window size ≠ attention budget. Focused context outperforms large context. |