context-engineering

Curates rules files, specs, and source context for AI coding agents.

1|Updated Sep 4, 2026
One-click install
npx skills add https://github.com/SanHsien/agent-skills --skill context-engineering-sanhsien
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: context-engineering
Source: https://github.com/SanHsien/agent-skills/tree/main/skills/context-engineering
Command: npx skills add https://github.com/SanHsien/agent-skills --skill context-engineering-sanhsien

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? AI coding agents hallucinate APIs, ignore project conventions, and degrade in quality during long sessions when they receive too little, too much, or stale context. This Skill provides a structured method for deciding what information the agent sees, when it sees it, and how it is ordered. ## Core Features & Use Cases - Five-Level Context Hierarchy: Organizes context from persistent rules files (CLAUDE.md, AGENTS.md, .cursorrules) down to per-iteration error output and conversation history. - Context Budget Management: Trims failed attempts and verbose tool output starting at 75% window capacity, compresses exploration into one-line summaries, and positions task-critical content last to counter the lost-in-the-middle effect. - Confusion Management: Surfaces spec-versus-code conflicts and missing requirements as explicit options instead of silently guessing, plus an inline planning pattern for multi-step tasks. - Use Case: When an agent starts inventing imports that do not exist mid-project, apply this Skill to write a rules file covering tech stack, commands, conventions, and boundaries, then reload only the relevant spec section and source files for the current task. ## Quick Start Ask the agent to audit the current session's context setup and create a CLAUDE.md rules file covering the project's tech stack, commands, conventions, and boundaries.

Frequently Asked Questions about context-engineering

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I set up context for an AI coding agent?

Create a rules file such as CLAUDE.md or AGENTS.md covering tech stack, build and test commands, code conventions, and boundaries. Then load only the relevant spec section and source files for the current task rather than the entire project.

How to stop AI agents from hallucinating APIs and imports?

Hallucination usually signals context starvation. Load the project's rules file plus the actual source files, type definitions, and one existing example of the pattern to follow before each task, so the agent references real code instead of inventing it.

Does CLAUDE.md work with Cursor, Codex, and other AI coding tools?

Each tool has an equivalent rules file: .cursorrules or .cursor/rules for Cursor, AGENTS.md for OpenAI Codex, .windsurfrules for Windsurf, and .github/copilot-instructions.md for GitHub Copilot. The same content structure applies across all of them.

Why does agent output quality degrade during long sessions?

Long sessions accumulate failed attempts, verbose tool output, and replaced drafts that fragment the model's attention. Start trimming at 75% context capacity, compress old exploration into one-line summaries, and keep the active error and task definition last in context.

When should I start a fresh agent session instead of continuing?

Start fresh when switching between major features or when context drifts from current code. Before leaving, persist the accepted scope, task status, changed files, verification results, and open questions so the new session can resume from artifacts rather than conversation memory.