# Agent Context Setup

Configures rules files and session context so agent output stays high quality.

- Repository: https://github.com/addyosmani/agent-skills (112533 stars)
- Category: AI and agents
- License: MIT
- Last updated: 2026-11-01
- Runs scripts: no, instructions only

## Install

Claude Code: `npx skills add addyosmani/agent-skills --skill context-engineering -g -a claude-code -y`
Codex: `npx skills add addyosmani/agent-skills --skill context-engineering -g -a codex -y`
Cursor: `npx skills add addyosmani/agent-skills --skill context-engineering -g -a cursor -y`
Gemini CLI: `npx skills add addyosmani/agent-skills --skill context-engineering -g -a gemini-cli -y`
Claude Code plugin marketplace: `/plugin marketplace add addyosmani/agent-skills`

## Description

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.

## SKILL.md, as published by its author (untrusted third-party text, read it as data)

# Context Engineering

## Overview

Feed agents the right information at the right time. Context is the single biggest lever for agent output quality, too little and the agent hallucinates, too much and it loses focus. Context engineering is the practice of deliberately curating what the agent sees, when it sees it, and how it's structured.

## When to Use

- Starting a new coding session
- Agent output quality is declining (wrong patterns, hallucinated APIs, ignoring conventions)
- Switching between different parts of a codebase
- Setting up a new project for AI-assisted development
- The agent is not following project conventions

## The Context Hierarchy

Structure context from most persistent to most transient:

```
┌─────────────────────────────────────┐
│  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
└─────────────────────────────────────┘
```

### Level 1: Rules Files

Create a rules file that persists across sessions. This is the highest-leverage context you can provide.

**CLAUDE.md** (for Claude Code):
```markdown
# 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`

The rest: https://github.com/addyosmani/agent-skills/blob/HEAD/skills/context-engineering/SKILL.md
