[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M77PDX5ZGS7VW0JE2AAC325V":3,"skill-same:01M77PDX5ZGS7VW0JE2AAC325V":57},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":24,"commitSha":25,"skillDirectory":26,"forksCount":14,"repositoryHtmlUrl":27,"repositoryHomepageUrl":6,"ownerHtmlUrl":28,"ownerBlogUrl":6,"ownerDescription":29,"updatedAt":30,"install":31,"resources":44},"01M77PDX5ZGS7VW0JE2AAC325V","filesystem-context",null,"This skill should be used when agent work needs file-backed context: durable scratchpads, tool-output offloading, just-in-time discovery, cross-agent handoff files, filesystem memory, or cleanup policies for context stored outside the prompt.","ziyad455\u002Fsophia","ziyad455","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F182938716?v=4","01M77PD51CNRHPXKBGHFNHRNSH","Ziyad Tber","01M77PD522JQ9SM0TM19PPPTYV",0,"MIT","https:\u002F\u002Fgithub.com\u002Fziyad455\u002Fsophia\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Ffilesystem-context\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: filesystem-context\ndescription: \"This skill should be used when agent work needs file-backed context: durable scratchpads, tool-output offloading, just-in-time discovery, cross-agent handoff files, filesystem memory, or cleanup policies for context stored outside the prompt.\"\n---\n\n# Filesystem-Based Context Engineering\n\nUse the filesystem as the primary overflow layer for agent context because context windows are limited while tasks often require more information than fits in a single window. Files let agents store, retrieve, and update an effectively unlimited amount of context through a single interface.\n\nPrefer dynamic context discovery -- pulling relevant context on demand -- over static inclusion, because static context consumes tokens regardless of relevance and crowds out space for task-specific information.\n\n## When to Activate\n\nActivate this skill when:\n- Tool outputs are bloating the context window\n- Agents need to persist state across long trajectories\n- Sub-agents must share information without direct message passing\n- Tasks require more context than fits in the window\n- Building agents that learn and update their own instructions\n- Implementing scratch pads for intermediate results\n- Terminal outputs or logs need to be accessible to agents\n\nDo not activate this skill for adjacent work owned by other skills:\n- Semantic cross-session memory, entity tracking, or temporal knowledge graphs: `memory-systems`.\n- Conversation summarization, compaction, or durable handoff wording: `context-compression`.\n- Token-efficiency tactics that do not require file-backed storage: `context-optimization`.\n- Multi-agent topology or handoff protocol design: `multi-agent-patterns`.\n\n## Core Concepts\n\nDiagnose context failures against these four modes, because each requires a different filesystem remedy:\n\n1. **Missing context** -- needed information is absent from the total available context. Fix by persisting tool outputs and intermediate results to files so nothing is lost.\n2. **Under-retrieved context** -- retrieved content fails to encapsulate what the agent needs. Fix by structuring files for targeted retrieval (grep-friendly formats, clear section headers).\n3. **Over-retrieved context** -- retrieved content far exceeds what is needed, wasting tokens and degrading attention. Fix by offloading bulk content to files and returning compact references.\n4. **Buried context** -- niche information is hidden across many files. Fix by combining glob and grep for structural search alongside semantic search for conceptual queries.\n\nUse the filesystem as the persistent layer that addresses all four: write once, store durably, retrieve selectively.\n\n## Detailed Topics\n\n### The Static vs Dynamic Context Trade-off\n\nTreat static context (system instructions, tool definitions, critical rules) as expensive real estate -- it consumes tokens on every turn regardless of relevance. As agents accumulate capabilities, static context grows and crowds out dynamic information.\n\nUse dynamic context discovery instead: include only minimal static pointers (names, one-line descriptions, file paths) and load full content with search tools when relevant. This is more token-efficient and often improves response quality by reducing contradictory or irrelevant information in the window.\n\nAccept the trade-off: dynamic discovery requires the model to recognize when it needs more context. Current frontier models handle this well, but less capable models may fail to trigger loads. When in doubt, err toward including critical safety or correctness constraints statically.\n\n### Pattern 1: Filesystem as Scratch Pad\n\nRedirect large tool outputs to files instead of returning them directly to context, because a single web search or database query can dump thousands of tokens into message history where they persist for the entire conversation.\n\nWrite the output to a scratch file, extract a compact summary, and return a file reference. The agent then uses targeted retrieval (grep for patterns, read with line ranges) to access only what it needs.\n\n```python\ndef handle_tool_output(output: str, threshold: int = 2000) -> str:\n    if len(output) \u003C threshold:\n        return output\n\n    file_path = f\"scratch\u002F{tool_name}_{timestamp}.txt\"\n    write_file(file_path, output)\n\n    key_summary = extract_summary(output, max_tokens=200)\n    return f\"[Output written to {file_path}. Summary: {key_summary}]\"\n```\n\nUse grep to search the offloaded file and read_file with line ranges to retrieve targeted sections, because this preserves full output for later reference while keeping only ~100 tokens in the active context.\n\n### Pattern 2: Plan Persistence\n\nWrite plans to the filesystem because long-horizon tasks lose coherence when plans fall out of attention or get summarized away. The agent re-reads its plan at any point, restoring awareness of the objective and progress.\n\nStore plans in structured format so they are both human-readable and machine-parseable:\n```yaml\n# scratch\u002Fcurrent_plan.yaml\nobjective: \"Refactor authentication module\"\nstatus: in_progress\nsteps:\n  - id: 1\n    description: \"Audit current auth endpoints\"\n    status: completed\n  - id: 2\n    description: \"Design new token validation flow\"\n    status: in_progress\n  - id: 3\n    description: \"Implement and test changes\"\n    status: pending\n```\n\nRe-read the plan at the start of each turn or after any context refresh to re-orient, because this acts as \"manipulating attention through recitation.\"\n\n### Pattern 3: Sub-Agent Communication via Filesystem\n\nRoute sub-agent findings through the filesystem instead of message passing, because multi-hop message chains degrade information through summarization at each hop (\"game of telephone\").\n\nHave each sub-agent write directly to its own workspace directory. The coordinator reads these files directly, preserving full fidelity:\n```\nworkspace\u002F\n  agents\u002F\n    research_agent\u002F\n      findings.md\n      sources.jsonl\n    code_agent\u002F\n      changes.md\n      test_results.txt\n  coordinator\u002F\n    synthesis.md\n```\n\nEnforce per-agent directory isolation to prevent write conflicts and maintain clear ownership of each output artifact.\n\n### Pattern 4: Dynamic Skill Loading\n\nStore skills as files and include only skill names with brief descriptions in static context, because stuffing all instructions into the system prompt wastes tokens and can confuse the model with contradictory guidance.\n\n```\nAvailable skills (load with read_file when relevant):\n- database-optimization: Query tuning and indexing strategies\n- api-design: REST\u002FGraphQL best practices\n- testing-strategies: Unit, integration, and e2e testing patterns\n```\n\nLoad the full skill file (e.g., `skills\u002Fdatabase-optimization\u002FSKILL.md`) only when the current task requires it. This converts O(n) static token cost into O(1) per task.\n\n### Pattern 5: Terminal and Log Persistence\n\nPersist terminal output to files automatically and use grep for selective retrieval, because terminal output from long-running processes accumulates rapidly and manual copy-paste is error-prone.\n\n```\nterminals\u002F\n  1.txt    # Terminal session 1 output\n  2.txt    # Terminal session 2 output\n```\n\nQuery with targeted grep (`grep -A 5 \"error\" terminals\u002F1.txt`) instead of loading entire terminal histories into context.\n\n### Pattern 6: Learning Through Self-Modification\n\nHave agents write learned preferences and patterns to their own instruction files so subsequent sessions load this context automatically, instead of requiring manual system prompt updates.\n\n```python\ndef remember_preference(key: str, value: str):\n    preferences_file = \"agent\u002Fuser_preferences.yaml\"\n    prefs = load_yaml(preferences_file)\n    prefs[key] = value\n    write_yaml(preferences_file, prefs)\n```\n\nGuard this pattern with validation because self-modification can accumulate incorrect or contradictory instructions over time. Treat it as experimental -- review persisted preferences periodically.\n\n### Filesystem Search Techniques\n\nCombine `ls`\u002F`list_dir`, `glob`, `grep`, and `read_file` with line ranges for context discovery, because models are specifically trained on filesystem traversal and this combination often outperforms semantic search for technical content where structural patterns are clear.\n\n- `ls` \u002F `list_dir`: Discover directory structure\n- `glob`: Find files matching patterns (e.g., `**\u002F*.py`)\n- `grep`: Search file contents, returns matching lines with context\n- `read_file` with ranges: Read specific sections without loading entire files\n\nUse filesystem search for structural and exact-match queries, and semantic search for conceptual queries. Combine both for comprehensive discovery.\n\n## Practical Guidance\n\n### When to Use Filesystem Context\n\nApply filesystem patterns when the situation matches these criteria, because they add I\u002FO overhead that is only justified by token savings or persistence needs:\n\n**Use when:**\n- Tool outputs exceed ~2000 tokens\n- Tasks span multiple conversation turns\n- Multiple agents need shared state\n- Skills or instructions exceed comfortable system prompt size\n- Logs or terminal output need selective querying\n\n**Avoid when:**\n- Tasks complete in single turns (overhead not justified)\n- Context fits comfortably in window (no problem to solve)\n- Latency is critical (file I\u002FO adds measurable delay)\n- Model lacks filesystem tool capabilities\n\n### File Organization\n\nStructure files for agent discoverability, because agents navigate by listing and reading directory names:\n```\nproject\u002F\n  scratch\u002F           # Temporary working files\n    tool_outputs\u002F    # Large tool results\n    plans\u002F           # Active plans and checklists\n  memory\u002F            # Persistent learned information\n    preferences.yaml # User preferences\n    patterns.md      # Learned patterns\n  skills\u002F            # Loadable skill definitions\n  agents\u002F            # Sub-agent workspaces\n```\n\nUse consistent naming conventions and include timestamps or IDs in scratch files for disambiguation.\n\nFor autonomous research loops, store raw retrieved evidence under the run that consumed it, for example `researcher\u002Fruns\u002F\u003Crun-id>\u002Fsources\u002Fevidence\u002Fraw\u002F`. Do not leave raw research dumps in the repository root; root-level artifacts become hard to audit and easy to cite without provenance.\n\n### Token Accounting\n\nMeasure where tokens originate before and after applying filesystem patterns, because optimizing without measurement leads to wasted effort:\n- Track static vs dynamic context ratio\n- Monitor tool output sizes before and after offloading\n- Measure how often dynamically-loaded context is actually used\n\n## Examples\n\n**Example 1: Tool Output Offloading**\n```\nInput: Web search returns 8000 tokens\nBefore: 8000 tokens added to message history\nAfter:\n  - Write to scratch\u002Fsearch_results_001.txt\n  - Return: \"[Results in scratch\u002Fsearch_results_001.txt. Key finding: API rate limit is 1000 req\u002Fmin]\"\n  - Agent greps file when needing specific details\nResult: ~100 tokens in context, 8000 tokens accessible on demand\n```\n\n**Example 2: Dynamic Skill Loading**\n```\nInput: User asks about database indexing\nStatic context: \"database-optimization: Query tuning and indexing\"\nAgent action: read_file(\"skills\u002Fdatabase-optimization\u002FSKILL.md\")\nResult: Full skill loaded only when relevant\n```\n\n**Example 3: Chat History as File Reference**\n```\nTrigger: Context window limit reached, summarization required\nAction:\n  1. Write full history to history\u002Fsession_001.txt\n  2. Generate summary for new context window\n  3. Include reference: \"Full history in history\u002Fsession_001.txt\"\nResult: Agent can search history file to recover details lost in summarization\n```\n\n## Guidelines\n\n1. Write large outputs to files; return summaries and references to context\n2. Store plans and state in structured files for re-reading\n3. Use sub-agent file workspaces instead of message chains\n4. Load skills dynamically rather than stuffing all into system prompt\n5. Persist terminal and log output as searchable files\n6. Combine grep\u002Fglob with semantic search for comprehensive discovery\n7. Organize files for agent discoverability with clear naming\n8. Measure token savings to validate filesystem patterns are effective\n9. Implement cleanup for scratch files to prevent unbounded growth\n10. Guard self-modification patterns with validation\n11. Keep raw evidence next to the run, evaluation, and proposal that used it\n\n## Gotchas\n\n1. **Scratch directory unbounded growth**: Agents create temp files without cleanup, eventually consuming disk and making directory listings noisy. Implement a retention policy (age-based or count-based) and run cleanup at session boundaries.\n2. **Race conditions in multi-agent file access**: Concurrent writes to the same file corrupt state silently. Enforce per-agent directory isolation or use append-only files with agent-prefixed entries.\n3. **Stale file references after moves\u002Frenames**: Agents hold paths from prior turns that no longer exist after refactors or file reorganization. Always verify file existence before reading a cached path; re-discover with glob if the check fails.\n4. **Glob pattern false matches**: Overly broad patterns (e.g., `**\u002F*`) pull irrelevant files into context, wasting tokens and confusing the model. Scope globs to specific directories and extensions.\n5. **File size assumptions**: Reading a file without checking size can dump 100K+ tokens into context in a single tool call. Check file size before reading; use line-range reads for large files.\n6. **Missing file existence checks**: Agents assume files exist from prior turns, but they may have been deleted or moved. Always guard reads with existence checks and handle missing-file errors gracefully.\n7. **Scratch pad format drift**: Unstructured scratch pads become unparseable after many writes because format conventions erode over successive appends. Define and enforce a schema (YAML, JSON, or structured markdown) from the first write.\n8. **Hardcoded absolute paths**: Break when repositories are checked out at different locations or when running in containers. Use relative paths from the project root or resolve paths dynamically.\n\n## Integration\n\nThis skill owns file-backed context storage and retrieval. Adjacent skills own semantic memory, summarization, and topology:\n\n- `context-optimization`: filesystem offloading is one implementation of observation masking when full outputs remain retrievable.\n- `memory-systems`: use when file-backed notes are no longer enough and semantic, entity, or temporal retrieval is required.\n- `multi-agent-patterns`: sub-agent file workspaces enable context isolation and direct handoff.\n- `context-compression`: file references can anchor summaries and preserve details omitted from compressed context.\n- `tool-design`: tools should return file references for large outputs and expose safe read\u002Fsearch operations.\n\n## References\n\nInternal reference:\n- [Implementation Patterns](.\u002Freferences\u002Fimplementation-patterns.md) - Read when: implementing scratch pad, plan persistence, or tool output offloading and need concrete code beyond the inline examples\n\nRelated skills in this collection:\n- context-optimization - Read when: applying token reduction techniques alongside filesystem offloading\n- memory-systems - Read when: building persistent storage that outlasts a single session\n- multi-agent-patterns - Read when: designing agent coordination with shared file workspaces\n\nExternal resources:\n- LangChain Deep Agents — Read when: implementing filesystem-based context patterns in LangChain\u002FLangGraph pipelines\n- Cursor context discovery — Read when: studying how production IDEs implement dynamic context loading\n- Anthropic Agent Skills specification — Read when: building skills that leverage filesystem progressive disclosure\n\n---\n\n## Skill Metadata\n\n**Created**: 2026-01-07\n**Last Updated**: 2026-05-15\n**Author**: Agent Skills for Context Engineering Contributors\n**Version**: 1.2.0\n","# Filesystem-Based Context Engineering\n\nUse the filesystem as the primary overflow layer for agent context because context windows are limited while tasks often require more information than fits in a single window. Files let agents store, retrieve, and update an effectively unlimited amount of context through a single interface.\n\nPrefer dynamic context discovery -- pulling relevant context on demand -- over static inclusion, because static context consumes tokens regardless of relevance and crowds out space for task-specific information.\n\n## When to Activate\n\nActivate this skill when:\n- Tool outputs are bloating the context window\n- Agents need to persist state across long trajectories\n- Sub-agents must share information without direct message passing\n- Tasks require more context than fits in the window\n- Building agents that learn and update their own instructions\n- Implementing scratch pads for intermediate results\n- Terminal outputs or logs need to be accessible to agents\n\nDo not activate this skill for adjacent work owned by other skills:\n- Semantic cross-session memory, entity tracking, or temporal knowledge graphs: `memory-systems`.\n- Conversation summarization, compaction, or durable handoff wording: `context-compression`.\n- Token-efficiency tactics that do not require file-backed storage: `context-optimization`.\n- Multi-agent topology or handoff protocol design: `multi-agent-patterns`.\n\n## Core Concepts\n\nDiagnose context failures against these four modes, because each requires a different filesystem remedy:\n\n1. **Missing context** -- needed information is absent from the total available context. Fix by persisting tool outputs and intermediate results to files so nothing is lost.\n2. **Under-retrieved context** -- retrieved content fails to encapsulate what the agent needs. Fix by structuring files for targeted retrieval (grep-friendly formats, clear section headers).\n3. **Over-retrieved context** -- retrieved content far exceeds what is needed, wasting tokens and degrading attention. Fix by offloading bulk content to files and returning compact references.\n4. **Buried context** -- niche information is hidden across many files. Fix by combining glob and grep for structural search alongside semantic search for conceptual queries.\n\nUse the filesystem as the persistent layer that addresses all four: write once, store durably, retrieve selectively.\n\n## Detailed Topics\n\n### The Static vs Dynamic Context Trade-off\n\nTreat static context (system instructions, tool definitions, critical rules) as expensive real estate -- it consumes tokens on every turn regardless of relevance. As agents accumulate capabilities, static context grows and crowds out dynamic information.\n\nUse dynamic context discovery instead: include only minimal static pointers (names, one-line descriptions, file paths) and load full content with search tools when relevant. This is more token-efficient and often improves response quality by reducing contradictory or irrelevant information in the window.\n\nAccept the trade-off: dynamic discovery requires the model to recognize when it needs more context. Current frontier models handle this well, but less capable models may fail to trigger loads. When in doubt, err toward including critical safety or correctness constraints statically.\n\n### Pattern 1: Filesystem as Scratch Pad\n\nRedirect large tool outputs to files instead of returning them directly to context, because a single web search or database query can dump thousands of tokens into message history where they persist for the entire conversation.\n\nWrite the output to a scratch file, extract a compact summary, and return a file reference. The agent then uses targeted retrieval (grep for patterns, read with line ranges) to access only what it needs.\n\n```python\ndef handle_tool_output(output: str, threshold: int = 2000) -> str:\n    if len(output) \u003C threshold:\n        return output\n\n    file_path = f\"scratch\u002F{tool_name}_{timestamp}.txt\"\n    write_file(file_path, output)\n\n    key_summary = extract_summary(output, max_tokens=200)\n    return f\"[Output written to {file_path}. Summary: {key_summary}]\"\n```\n\nUse grep to search the offloaded file and read_file with line ranges to retrieve targeted sections, because this preserves full output for later reference while keeping only ~100 tokens in the active context.\n\n### Pattern 2: Plan Persistence\n\nWrite plans to the filesystem because long-horizon tasks lose coherence when plans fall out of attention or get summarized away. The agent re-reads its plan at any point, restoring awareness of the objective and progress.\n\nStore plans in structured format so they are both human-readable and machine-parseable:\n```yaml\n# scratch\u002Fcurrent_plan.yaml\nobjective: \"Refactor authentication module\"\nstatus: in_progress\nsteps:\n  - id: 1\n    description: \"Audit current auth endpoints\"\n    status: completed\n  - id: 2\n    description: \"Design new token validation flow\"\n    status: in_progress\n  - id: 3\n    description: \"Implement and test changes\"\n    status: pending\n```\n\nRe-read the plan at the start of each turn or after any context refresh to re-orient, because this acts as \"manipulating attention through recitation.\"\n\n### Pattern 3: Sub-Agent Communication via Filesystem\n\nRoute sub-agent findings through the filesystem instead of message passing, because multi-hop message chains degrade information through summarization at each hop (\"game of telephone\").\n\nHave each sub-agent write directly to its own workspace directory. The coordinator reads these files directly, preserving full fidelity:\n```\nworkspace\u002F\n  agents\u002F\n    research_agent\u002F\n      findings.md\n      sources.jsonl\n    code_agent\u002F\n      changes.md\n      test_results.txt\n  coordinator\u002F\n    synthesis.md\n```\n\nEnforce per-agent directory isolation to prevent write conflicts and maintain clear ownership of each output artifact.\n\n### Pattern 4: Dynamic Skill Loading\n\nStore skills as files and include only skill names with brief descriptions in static context, because stuffing all instructions into the system prompt wastes tokens and can confuse the model with contradictory guidance.\n\n```\nAvailable skills (load with read_file when relevant):\n- database-optimization: Query tuning and indexing strategies\n- api-design: REST\u002FGraphQL best practices\n- testing-strategies: Unit, integration, and e2e testing patterns\n```\n\nLoad the full skill file (e.g., `skills\u002Fdatabase-optimization\u002FSKILL.md`) only when the current task requires it. This converts O(n) static token cost into O(1) per task.\n\n### Pattern 5: Terminal and Log Persistence\n\nPersist terminal output to files automatically and use grep for selective retrieval, because terminal output from long-running processes accumulates rapidly and manual copy-paste is error-prone.\n\n```\nterminals\u002F\n  1.txt    # Terminal session 1 output\n  2.txt    # Terminal session 2 output\n```\n\nQuery with targeted grep (`grep -A 5 \"error\" terminals\u002F1.txt`) instead of loading entire terminal histories into context.\n\n### Pattern 6: Learning Through Self-Modification\n\nHave agents write learned preferences and patterns to their own instruction files so subsequent sessions load this context automatically, instead of requiring manual system prompt updates.\n\n```python\ndef remember_preference(key: str, value: str):\n    preferences_file = \"agent\u002Fuser_preferences.yaml\"\n    prefs = load_yaml(preferences_file)\n    prefs[key] = value\n    write_yaml(preferences_file, prefs)\n```\n\nGuard this pattern with validation because self-modification can accumulate incorrect or contradictory instructions over time. Treat it as experimental -- review persisted preferences periodically.\n\n### Filesystem Search Techniques\n\nCombine `ls`\u002F`list_dir`, `glob`, `grep`, and `read_file` with line ranges for context discovery, because models are specifically trained on filesystem traversal and this combination often outperforms semantic search for technical content where structural patterns are clear.\n\n- `ls` \u002F `list_dir`: Discover directory structure\n- `glob`: Find files matching patterns (e.g., `**\u002F*.py`)\n- `grep`: Search file contents, returns matching lines with context\n- `read_file` with ranges: Read specific sections without loading entire files\n\nUse filesystem search for structural and exact-match queries, and semantic search for conceptual queries. Combine both for comprehensive discovery.\n\n## Practical Guidance\n\n### When to Use Filesystem Context\n\nApply filesystem patterns when the situation matches these criteria, because they add I\u002FO overhead that is only justified by token savings or persistence needs:\n\n**Use when:**\n- Tool outputs exceed ~2000 tokens\n- Tasks span multiple conversation turns\n- Multiple agents need shared state\n- Skills or instructions exceed comfortable system prompt size\n- Logs or terminal output need selective querying\n\n**Avoid when:**\n- Tasks complete in single turns (overhead not justified)\n- Context fits comfortably in window (no problem to solve)\n- Latency is critical (file I\u002FO adds measurable delay)\n- Model lacks filesystem tool capabilities\n\n### File Organization\n\nStructure files for agent discoverability, because agents navigate by listing and reading directory names:\n```\nproject\u002F\n  scratch\u002F           # Temporary working files\n    tool_outputs\u002F    # Large tool results\n    plans\u002F           # Active plans and checklists\n  memory\u002F            # Persistent learned information\n    preferences.yaml # User preferences\n    patterns.md      # Learned patterns\n  skills\u002F            # Loadable skill definitions\n  agents\u002F            # Sub-agent workspaces\n```\n\nUse consistent naming conventions and include timestamps or IDs in scratch files for disambiguation.\n\nFor autonomous research loops, store raw retrieved evidence under the run that consumed it, for example `researcher\u002Fruns\u002F\u003Crun-id>\u002Fsources\u002Fevidence\u002Fraw\u002F`. Do not leave raw research dumps in the repository root; root-level artifacts become hard to audit and easy to cite without provenance.\n\n### Token Accounting\n\nMeasure where tokens originate before and after applying filesystem patterns, because optimizing without measurement leads to wasted effort:\n- Track static vs dynamic context ratio\n- Monitor tool output sizes before and after offloading\n- Measure how often dynamically-loaded context is actually used\n\n## Examples\n\n**Example 1: Tool Output Offloading**\n```\nInput: Web search returns 8000 tokens\nBefore: 8000 tokens added to message history\nAfter:\n  - Write to scratch\u002Fsearch_results_001.txt\n  - Return: \"[Results in scratch\u002Fsearch_results_001.txt. Key finding: API rate limit is 1000 req\u002Fmin]\"\n  - Agent greps file when needing specific details\nResult: ~100 tokens in context, 8000 tokens accessible on demand\n```\n\n**Example 2: Dynamic Skill Loading**\n```\nInput: User asks about database indexing\nStatic context: \"database-optimization: Query tuning and indexing\"\nAgent action: read_file(\"skills\u002Fdatabase-optimization\u002FSKILL.md\")\nResult: Full skill loaded only when relevant\n```\n\n**Example 3: Chat History as File Reference**\n```\nTrigger: Context window limit reached, summarization required\nAction:\n  1. Write full history to history\u002Fsession_001.txt\n  2. Generate summary for new context window\n  3. Include reference: \"Full history in history\u002Fsession_001.txt\"\nResult: Agent can search history file to recover details lost in summarization\n```\n\n## Guidelines\n\n1. Write large outputs to files; return summaries and references to context\n2. Store plans and state in structured files for re-reading\n3. Use sub-agent file workspaces instead of message chains\n4. Load skills dynamically rather than stuffing all into system prompt\n5. Persist terminal and log output as searchable files\n6. Combine grep\u002Fglob with semantic search for comprehensive discovery\n7. Organize files for agent discoverability with clear naming\n8. Measure token savings to validate filesystem patterns are effective\n9. Implement cleanup for scratch files to prevent unbounded growth\n10. Guard self-modification patterns with validation\n11. Keep raw evidence next to the run, evaluation, and proposal that used it\n\n## Gotchas\n\n1. **Scratch directory unbounded growth**: Agents create temp files without cleanup, eventually consuming disk and making directory listings noisy. Implement a retention policy (age-based or count-based) and run cleanup at session boundaries.\n2. **Race conditions in multi-agent file access**: Concurrent writes to the same file corrupt state silently. Enforce per-agent directory isolation or use append-only files with agent-prefixed entries.\n3. **Stale file references after moves\u002Frenames**: Agents hold paths from prior turns that no longer exist after refactors or file reorganization. Always verify file existence before reading a cached path; re-discover with glob if the check fails.\n4. **Glob pattern false matches**: Overly broad patterns (e.g., `**\u002F*`) pull irrelevant files into context, wasting tokens and confusing the model. Scope globs to specific directories and extensions.\n5. **File size assumptions**: Reading a file without checking size can dump 100K+ tokens into context in a single tool call. Check file size before reading; use line-range reads for large files.\n6. **Missing file existence checks**: Agents assume files exist from prior turns, but they may have been deleted or moved. Always guard reads with existence checks and handle missing-file errors gracefully.\n7. **Scratch pad format drift**: Unstructured scratch pads become unparseable after many writes because format conventions erode over successive appends. Define and enforce a schema (YAML, JSON, or structured markdown) from the first write.\n8. **Hardcoded absolute paths**: Break when repositories are checked out at different locations or when running in containers. Use relative paths from the project root or resolve paths dynamically.\n\n## Integration\n\nThis skill owns file-backed context storage and retrieval. Adjacent skills own semantic memory, summarization, and topology:\n\n- `context-optimization`: filesystem offloading is one implementation of observation masking when full outputs remain retrievable.\n- `memory-systems`: use when file-backed notes are no longer enough and semantic, entity, or temporal retrieval is required.\n- `multi-agent-patterns`: sub-agent file workspaces enable context isolation and direct handoff.\n- `context-compression`: file references can anchor summaries and preserve details omitted from compressed context.\n- `tool-design`: tools should return file references for large outputs and expose safe read\u002Fsearch operations.\n\n## References\n\nInternal reference:\n- [Implementation Patterns](.\u002Freferences\u002Fimplementation-patterns.md) - Read when: implementing scratch pad, plan persistence, or tool output offloading and need concrete code beyond the inline examples\n\nRelated skills in this collection:\n- context-optimization - Read when: applying token reduction techniques alongside filesystem offloading\n- memory-systems - Read when: building persistent storage that outlasts a single session\n- multi-agent-patterns - Read when: designing agent coordination with shared file workspaces\n\nExternal resources:\n- LangChain Deep Agents — Read when: implementing filesystem-based context patterns in LangChain\u002FLangGraph pipelines\n- Cursor context discovery — Read when: studying how production IDEs implement dynamic context loading\n- Anthropic Agent Skills specification — Read when: building skills that leverage filesystem progressive disclosure\n\n---\n\n## Skill Metadata\n\n**Created**: 2026-01-07\n**Last Updated**: 2026-05-15\n**Author**: Agent Skills for Context Engineering Contributors\n**Version**: 1.2.0\n",{"name":5,"description":7},"main","2d7111cf79ed41437a35c1f7982ce6adeac9ea6a",".agents\u002Fskills\u002Ffilesystem-context","https:\u002F\u002Fgithub.com\u002Fziyad455\u002Fsophia","https:\u002F\u002Fgithub.com\u002Fziyad455","I'm a Software Engineering  at INVENEO, passionate about building production-grade systems that make a real impact.","2026-08-21 00:57:14",{"source":8,"skillName":5,"commands":32,"prompt":42,"zipAvailable":43},[33,36,39],{"tool":34,"command":35},"npx","npx skills add ziyad455\u002Fsophia --skill filesystem-context",{"tool":37,"command":38},"bunx","bunx skills add ziyad455\u002Fsophia --skill filesystem-context",{"tool":40,"command":41},"pnpm","pnpm dlx skills add ziyad455\u002Fsophia --skill filesystem-context","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fziyad455\u002Fsophia\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Ffilesystem-context\u002FSKILL.md",true,[45,51],{"path":46,"resourceType":47,"resourceTypeDesc":48,"sizeBytes":49,"sourceHtmlUrl":50},"references\u002Fimplementation-patterns.md","REFERENCE","参考文档",18228,"https:\u002F\u002Fgithub.com\u002Fziyad455\u002Fsophia\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Ffilesystem-context\u002Freferences\u002Fimplementation-patterns.md",{"path":52,"resourceType":53,"resourceTypeDesc":54,"sizeBytes":55,"sourceHtmlUrl":56},"scripts\u002Ffilesystem_context.py","SCRIPT","脚本",15086,"https:\u002F\u002Fgithub.com\u002Fziyad455\u002Fsophia\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Ffilesystem-context\u002Fscripts\u002Ffilesystem_context.py",[58,65,72,79,86,93],{"skillNo":59,"name":60,"nameZh":6,"description":61,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":62,"categories":63,"keywords":64,"publishedAt":19},"01M77PHM6Q4CQ14JQM4VVJE25Q","accessibility","Audit and improve web accessibility following WCAG 2.2 guidelines. Use when asked to \"improve accessibility\", \"a11y audit\", \"WCAG compliance\", \"screen reader support\", \"keyboard navigation\", or \"make accessible\".","https:\u002F\u002Fgithub.com\u002Fziyad455\u002Fsophia\u002Fblob\u002Fmain\u002F.agents\u002Fwcag-accessibility\u002Fskill.md",[],[],{"skillNo":66,"name":67,"nameZh":6,"description":68,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":69,"categories":70,"keywords":71,"publishedAt":19},"01M77PHGJHGWS1HW164BJJH9JS","writing-guidelines","Review docs\u002Fprose for Writing Guidelines compliance. Use when asked to \"review my docs\", \"check writing style\", \"audit prose\", \"review docs voice and tone\", or \"check this page against the writing handbook\".","https:\u002F\u002Fgithub.com\u002Fziyad455\u002Fsophia\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fwriting-guidelines\u002FSKILL.md",[],[],{"skillNo":73,"name":74,"nameZh":6,"description":75,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":76,"categories":77,"keywords":78,"publishedAt":19},"01M77PHE6782TNB8X549EK94CX","web-design-guidelines","Review UI code for Web Interface Guidelines compliance. Use when asked to \"review my UI\", \"check accessibility\", \"audit design\", \"review UX\", or \"check my site against best practices\".","https:\u002F\u002Fgithub.com\u002Fziyad455\u002Fsophia\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fweb-design-guidelines\u002FSKILL.md",[],[],{"skillNo":80,"name":81,"nameZh":6,"description":82,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":83,"categories":84,"keywords":85,"publishedAt":19},"01M77PHBHHM68A2YTWN4JY1DH8","verification-before-completion","Use when about to claim work is complete, fixed, or passing, before committing or creating PRs - requires running verification commands and confirming output before making any success claims; evidence before assertions always","https:\u002F\u002Fgithub.com\u002Fziyad455\u002Fsophia\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fverification-before-completion\u002FSKILL.md",[],[],{"skillNo":87,"name":88,"nameZh":6,"description":89,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":90,"categories":91,"keywords":92,"publishedAt":19},"01M77PH43WZPAKS82NJYYHVA4N","vercel-react-view-transitions","Guide for implementing smooth, native-feeling animations using React's View Transition API (`\u003CViewTransition>` component, `addTransitionType`, and CSS view transition pseudo-elements). Use this skill whenever the user wants to add page transitions, animate route changes, create shared element animations, animate enter\u002Fexit of components, animate list reorder, implement directional (forward\u002Fback) navigation animations, or integrate view transitions in Next.js. Also use when the user mentions view transitions, `startViewTransition`, `ViewTransition`, transition types, or asks about animating between UI states in React without third-party animation libraries.","https:\u002F\u002Fgithub.com\u002Fziyad455\u002Fsophia\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fvercel-react-view-transitions\u002FSKILL.md",[],[],{"skillNo":94,"name":95,"nameZh":6,"description":96,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":97,"categories":98,"keywords":99,"publishedAt":19},"01M77PGXA9ST3M4DF7BF69EMRF","vercel-react-best-practices","React and Next.js performance optimization guidelines from Vercel Engineering. This skill should be used when writing, reviewing, or refactoring React\u002FNext.js code to ensure optimal performance patterns. Triggers on tasks involving React components, Next.js pages, data fetching, bundle optimization, or performance improvements.","https:\u002F\u002Fgithub.com\u002Fziyad455\u002Fsophia\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fvercel-react-best-practices\u002FSKILL.md",[],[]]