Skip to main content

agent-skills-context-engineering

Master context engineering principles for building production-grade AI agent systems with effective context management, multi-agent architectures, and memory systems.

Zur Installation springen

Quellinformationen

Repository
reason-machines/ai-agent-skills
Letzte Quellaktivität
16. Mai 2026 um 21:22
Erkannte Sprache von SKILL.md
Englisch
Sterne
1
Forks
1

Installationsoptionen

Standardmäßig ist der Prompt ausgewählt, der zuerst die Quelle prüft. Sie können zu einem direkten Befehl wechseln oder eine lokale Kopie herunterladen.

Quelldateien prüfen

Lesen Sie SKILL.md und alle von SkillsMP angezeigten Begleitdateien, bevor Sie sich für eine Installation entscheiden.

SKILL.md wird angezeigt

SKILL.md
Quellanweisungen · Schreibgeschützte Vorschau
name
agent-skills-context-engineering
description
Master context engineering principles for building production-grade AI agent systems with effective context management, multi-agent architectures, and memory systems.
triggers
["build agent system with context engineering","optimize agent context window usage","implement multi-agent architecture","design agent memory system","compress agent context for long sessions","debug agent context degradation","evaluate agent performance with LLM-as-judge","build hosted coding agent with sandboxes"]
# Agent Skills for Context Engineering > Skill by [ara.so](https://ara.so) — AI Agent Skills collection. A comprehensive collection of Agent Skills for context engineering, multi-agent architectures, and production agent systems. This skill teaches principles for managing LLM context windows, designing effective agent architectures, and building production-grade agent systems. ## What This Project Does Agent Skills for Context Engineering provides battle-tested patterns for: - **Context Management**: Managing limited attention budgets, avoiding lost-in-middle degradation - **Multi-Agent Systems**: Orchestrator, peer-to-peer, and hierarchical architectures - **Memory Systems**: Short-term, long-term, and graph-based memory patterns - **Tool Design**: Building tools that agents can use effectively - **Evaluation**: LLM-as-judge frameworks for measuring agent quality - **Production Systems**: Hosted agents with sandboxed VMs and multiplayer support Unlike prompt engineering (crafting instructions), context engineering addresses holistic curation of all information in the context window: system prompts, tool definitions, retrieved documents, message history, and tool outputs. ## Installation ### For Claude Code (Recommended) **Step 1: Add the Marketplace** ```bash /plugin marketplace add muratcankoylan/Agent-Skills-for-Context-Engineering ``` **Step 2: Install the Plugin** ```bash /plugin install context-engineering@context-engineering-marketplace ``` Or browse and install: 1. Select `Browse and install plugins` 2. Select `context-engineering-marketplace` 3. Select `context-engineering` 4. Select `Install now` ### For Cursor (Open Plugins) Add to your `.cursor/plugins.json`: ```json { "plugins": [ { "name": "context-engineering", "repository": "muratcankoylan/Agent-Skills-for-Context-Engineering" } ] } ``` ### For Individual Skills Copy specific skills to your project: ```bash # Create skills directory mkdir -p .claude/skills # Add a specific skill (example: context-fundamentals) curl -o .claude/skills/context-fundamentals.md \ https://raw.githubusercontent.com/muratcankoylan/Agent-Skills-for-Context-Engineering/main/skills/context-fundamentals/SKILL.md ``` Available skills: `context-fundamentals`, `context-degradation`, `context-compression`, `context-optimization`, `latent-briefing`, `multi-agent-patterns`, `memory-systems`, `tool-design`, `filesystem-context`, `hosted-agents`, `evaluation`, `advanced-evaluation`, `project-development`, `bdi-mental-states` ## Core Concepts ### Context Window Management The fundamental challenge: context windows are constrained by attention mechanics, not raw token capacity. **Key degradation patterns:** - **Lost-in-the-middle**: Models lose track of information in the middle of long contexts - **U-shaped attention**: Strong attention at beginning and end, weak in middle - **Attention scarcity**: As context grows, attention per token decreases **Solution**: Find the smallest possible set of high-signal tokens. ### Progressive Disclosure Load information only when needed: ```python # skills/__init__.py - Lazy loading pattern class SkillRegistry: def __init__(self): self._skills = {} self._loaded = set() def get_skill_summary(self, skill_name: str) -> dict: """Load only name and description initially.""" return { "name": skill_name, "description": self._get_description(skill_name) } def load_skill(self, skill_name: str) -> dict: """Load full skill content only when activated.""" if skill_name not in self._loaded: self._skills[skill_name] = self._read_skill_file(skill_name) self._loaded.add(skill_name) return self._skills[skill_name] ``` ### Context Compression Strategies **Sliding Window:** ```python def sliding_window_context(messages: list, window_size: int = 10) -> list: """Keep only recent messages.""" if len(messages) <= window_size: return messages # Always keep system message system_msgs = [m for m in messages if m["role"] == "system"] recent_msgs = messages[-window_size:] return system_msgs + recent_msgs ``` **Summarization:** ```python async def compress_with_summary(messages: list, llm_client) -> list: """Compress old messages into summary.""" if len(messages) < 20: return messages # Keep recent messages uncompressed to_compress = messages[1:-10] # Skip system message and recent 10 recent = messages[-10:] # Generate summary summary_prompt = f"Summarize these messages concisely:\n{to_compress}" summary = await llm_client.complete(summary_prompt) return [ messages[0], # System message {"role": "assistant", "content": f"[Summary of previous conversation: {summary}]"}, *recent ] ``` ## Multi-Agent Patterns ### Orchestrator Pattern Single coordinator delegates to specialized workers: ```python from typing import List, Dict class OrchestratorAgent: def __init__(self, workers: Dict[str, Agent]): self.workers = workers async def process_task(self, task: str) -> str: # Determine which worker to use worker_name = await self._route_task(task) worker = self.workers[worker_name] # Delegate to worker with minimal context result = await worker.execute(task) return result async def _route_task(self, task: str) -> str: """Use LLM to determine which worker handles task.""" routing_prompt = f"""Given this task: {task} Available workers: - code_writer: Writes and modifies code - researcher: Gathers information and analyzes data - reviewer: Reviews code and provides feedback Which worker should handle this? Respond with just the worker name.""" return await self.llm.complete(routing_prompt) # Usage orchestrator = OrchestratorAgent({ "code_writer": CodeWriterAgent(), "researcher": ResearcherAgent(), "reviewer": ReviewerAgent() }) result = await orchestrator.process_task("Add error handling to the API client") ``` ### Peer-to-Peer Pattern Agents collaborate directly: ```python class PeerAgent: def __init__(self, name: str, peers: List['PeerAgent']): self.name = name self.peers = peers self.messages = [] async def broadcast(self, message: str): """Send message to all peers.""" for peer in self.peers: await peer.receive(self.name, message) async def receive(self, sender: str, message: str): """Receive message from peer.""" self.messages.append({ "from": sender, "content": message, "timestamp": time.time() }) ``` ## Memory Systems ### Short-term Memory (Working Context) ```python class WorkingMemory: def __init__(self, max_items: int = 5): self.items = [] self.max_items = max_items def add(self, item: dict): """Add item, removing oldest if at capacity.""" self.items.append(item) if len(self.items) > self.max_items: self.items.pop(0) def get_context(self) -> str: """Format for inclusion in prompt.""" return "\n".join([ f"- {item['key']}: {item['value']}" for item in self.items ]) ``` ### Long-term Memory (Retrieval) ```python import chromadb from typing import List, Dict class LongTermMemory: def __init__(self): self.client = chromadb.Client() self.collection = self.client.create_collection("agent_memory") def store(self, content: str, metadata: dict = None): """Store information for later retrieval.""" self.collection.add( documents=[content], metadatas=[metadata or {}], ids=[str(hash(content))] ) def recall(self, query: str, n_results: int = 3) -> List[Dict]: """Retrieve relevant memories.""" results = self.collection.query( query_texts=[query], n_results=n_results ) return [ { "content": doc, "metadata": meta } for doc, meta in zip(results['documents'][0], results['metadatas'][0]) ] ``` ### Graph-based Memory ```python import networkx as nx class GraphMemory: def __init__(self): self.graph = nx.DiGraph() def add_entity(self, entity: str, properties: dict): """Add or update entity node.""" self.graph.add_node(entity, **properties) def add_relation(self, from_entity: str, to_entity: str, relation: str): """Add relationship between entities.""" self.graph.add_edge(from_entity, to_entity, relation=relation) def get_neighbors(self, entity: str, max_depth: int = 2) -> dict: """Get connected entities within depth.""" if entity not in self.graph: return {} # BFS to find neighbors neighbors = {} for node in nx.single_source_shortest_path_length( self.graph, entity, cutoff=max_depth ): neighbors[node] = self.graph.nodes[node] return neighbors ``` ## Tool Design Principles ### Minimal Interface ```python from typing import Dict, Any def search_documentation(query: str, max_results: int = 5) -> list[Dict[str, Any]]: """Search documentation with minimal parameters. Args: query: Search query string max_results: Maximum number of results to return (default: 5) Returns: List of matching documentation sections with title and content Example: results = search_documentation("authentication") """ # Implementation pass ``` ### Clear Output Format ```python def analyze_code(code: str) -> dict: """Analyze code and return structured results. Returns: { "issues": [{"line": int, "severity": str, "message": str}], "metrics": {"complexity": int, "lines": int}, "suggestions": [str] } """ return { "issues": [ {"line": 15, "severity": "warning", "message": "Unused variable 'x'"} ], "metrics": { "complexity": 7, "lines": 42 }, "suggestions": [ "Consider extracting this logic into a separate function" ] } ``` ### Context Offloading ```python import json from pathlib import Path def analyze_large_dataset(data_path: str, output_dir: str = ".agent_context") -> str: """Analyze data and write detailed results to file. Returns reference to results file instead of full data in context. """ # Create context directory Path(output_dir).mkdir(exist_ok=True) # Analyze data results = perform_analysis(data_path) # Write detailed results to file results_file = f"{output_dir}/analysis_results.json" with open(results_file, 'w') as f: json.dump(results, f, indent=2) # Return only summary in context summary = { "total_records": results["count"], "key_findings": results["top_insights"][:3], "full_results": results_file } return f"Analysis complete. Summary: {summary}\nFull results in {results_file}" ``` ## Filesystem-based Context Management ### Dynamic Discovery ```python from pathlib import Path import yaml def discover_tools(tools_dir: str = ".agent_tools") -> dict: """Dynamically discover available tools from filesystem.""" tools = {} for tool_file in Path(tools_dir).glob("*.yaml"): with open(tool_file) as f: tool_spec = yaml.safe_load(f) tools[tool_spec["name"]] = tool_spec return tools # Tool definition file: .agent_tools/github_search.yaml """ name: github_search description: Search GitHub repositories parameters: - name: query type: string required: true - name: language type: string required: false """ ``` ### Plan Persistence ```python import json from datetime import datetime class PlanTracker: def __init__(self, plan_file: str = ".agent_context/current_plan.json"): self.plan_file = plan_file def save_plan(self, steps: list):
Auf GitHub ansehen
Diese SKILL.md ist sehr gross, daher zeigt SkillsMP hier nur den ersten Abschnitt. Auf GitHub ansehen