← ClaudeAtlas

context-injectionlisted

Place trusted contextual information into prompts or agent state using explicit boundaries, provenance, and templates. Use when relevant context has already been selected and must be inserted safely; use context-retrieval to find it or context-optimization to choose and order it.
seb1n/awesome-ai-agent-skills · ★ 254 · AI & Automation · score 81
Install: claude install-skill seb1n/awesome-ai-agent-skills
# Context Injection Context injection is the practice of dynamically inserting relevant information — documents, data, examples, or tool outputs — into an AI prompt so the model has the knowledge it needs to produce accurate, grounded responses. Effective injection is about more than pasting text; it requires deliberate placement, formatting, and token budget allocation to maximize the model's ability to use the injected material. ## Workflow 1. **Identify the Context Need**: Analyze the task to determine what types of external information the model requires. A code review needs the source file; a support question needs product documentation; a personalized reply needs the user's profile. Clearly categorize each need as document grounding, few-shot examples, tool output, or metadata. 2. **Gather the Context**: Retrieve the necessary information from its source — a database, file system, API response, vector store, or prior conversation. Apply any necessary compression or truncation before injection so the material fits within the allocated token budget. 3. **Select an Injection Strategy**: Choose the appropriate injection method based on the context type and the model's attention patterns: - *System prompt injection* — persistent context like role definitions, rules, and user preferences go in the system message. - *Document grounding* — retrieved documents or files are inserted in the user message, typically before the question. - *Few-shot examples* — input/ou