The Context Substrate in Practice
Produces an entitlement-preserving retrieval layer, an indexed catalog, and an evaluated set of instruction files.
An entitlement-preserving retrieval layer, an indexed catalog of code and ownership, and a short, evaluated set of instruction files.
Early. Section 8.1 identifies this as the platform layer with the largest measured effect, and it is the one most often deferred in favor of buying tools.
28.1 Build the Substrate, Not the Markdown #
The evidence here is genuinely contested and it points away from where most organizations put their effort.
Instruction files improve efficiency and probably not success. A controlled study across multiple models and agents, using both generated and developer-written context files, found that “providing context files does not generally improve task success rates, while increasing inference cost by over 20% on average.”131 A paired within-task study of 124 pull requests found median wall-clock time down 28.6 percent and median output tokens down 16.6 percent, while explicitly not evaluating task success.132 A field study of 15,549 agentic pull requests across 148 projects found near-symmetric outcomes: 27.7 percent of projects raised merge rate by at least 20 percent after introducing an instruction file, and 26.4 percent lowered it by at least 20 percent.133
Retrieval is where the measurable failure is. Across 427 samples from 25 repositories, interactive agents never accessed the relevant files on 27 to 35 percent of samples despite exploration, and the median relevant evidence occupies only 4.7 percent of the file containing it.203 Context acquisition is a distinct failure surface from patch generation, and it is the one with room to move.
So: index the code, expose the catalog, preserve entitlements, and keep the markdown short.
28.2 Entitlement-Preserving Retrieval #
This is the single property to copy first, and one published enterprise implementation states it directly: internal tool-protocol servers front the wiki, product management system, data warehouse, CRM, and workspace, preserving existing user permissions so agents retrieve only what the invoking human can already see.204
The procedure is short and the verification is the part that matters.
Resolve the invoking human’s identity at the start of every session and carry it as the retrieval principal.
Enforce entitlement at the data layer, not by filtering results after retrieval. Filtering after means the content transited the model before being removed.
Scope the index itself by classification, so that regulated data requires a separate, separately authorized path.
Instruct a test agent to retrieve something the invoking human cannot see and confirm refusal. A policy statement is not this step.
28.3 What to Index #
In descending order of measured or plausible value:
Code, semantically. The index earns its keep as repository size grows: the vendor advocating indexing reports code retention improving 0.3 percent overall but 2.6 percent on codebases over a thousand files.137 Two major vendors hold publicly opposite positions here, each publishing evidence favoring its own architecture, so the honest reading is scale-dependence rather than a settled answer.136,137
The service catalog and ownership topology. One published implementation injects component architecture, dependency graphs, ownership topology, and architectural decisions into agent sessions from its internal developer portal, with session transcripts flowing back into the same portal, making the catalog both the context source and the audit surface.195
Architecture decisions. ADRs as retrievable context are the mechanism by which an agent can know why the codebase is shaped as it is. This is reasoning rather than measurement; no study has isolated the effect.
A component catalog answering “does something like this already exist.” This is the most useful counter to the duplication trend in Section 3.6, where refactoring fell from 21 percent of changed lines to 3.8 percent while copy-paste rose from 9.4 to 15.7 percent.38 Nothing in a generative workflow rewards finding the existing implementation.
A knowledge graph, if you are large enough. One organization operates a context graph of roughly 40 million entries across about 150 node and edge types, explicitly built to reduce tokens, turns, and latency.103 That is evidenced by essentially one company via a conference talk. Treat it as promising and single-sourced.
28.4 Instruction Files: Short, Specific, Evaluated #
Given the null results, the defensible posture is narrow.
Include non-obvious house rules an agent cannot infer, build and test invocation, conventions that differ from ecosystem defaults, and security content, which is almost always missing: a study of 2,303 context files found testing content in 75 percent, implementation detail in 69.9 percent, and architecture in 67.7 percent, with security and performance each appearing in only 14.5 percent.134 Published guidance exists on what security content belongs there, including preferring well-vetted libraries, using official package managers, pinning versions, and verifying integrity by checksum or signature.99
Exclude repository overviews, which are the part vendors most commonly recommend generating and the part with the least support.131
Evaluate rather than generate. Before rolling a file out, run the same corpus of tasks with and without it and compare success, cost, and review rework. Projects that improved had files with a median of 976 words against 569 for projects that declined, so length and structure matter, but your own measurement matters more than either number.133
Review them as code, because they are an execution surface. Across the disclosed vulnerabilities in agentic development tooling, the vulnerable object is repeatedly the configuration file rather than the code.19,20,21,22
28.5 Instrumentation #
- Retrieval coverage: share of repositories indexed, and share of sessions where the agent reached the relevant file
- Adversarial retrieval test result, refreshed on every substrate change
- Instruction file effect: paired task success and cost, per file, before and after
- Duplication and reuse trend, as the outcome measure for the component catalog
- Median tokens per session, which is where substrate improvements show up first
28.6 Failure Signatures #
- Retrieval scoped by prompt. “Only look at what the user can see” is an instruction. Entitlement belongs at the data layer.
- Instruction files that grow. They accumulate because adding a line is easier than diagnosing a failure. Cap the length, review on change, and re-evaluate periodically.
- Generated repository overviews. The specific artifact the evidence does not support, and the one most commonly auto-produced.
- The catalog nobody queries. If agent sessions do not reach it, it is documentation with an API.
28.7 What This Rests On #
The context-file null results, the efficiency effect, the field outcome distribution, the retrieval failure rate, the content-composition study, and the indexing scale effect are all measured, though several are preprints and two are vendor-published with opposing conclusions.131,132,133,203,134,136,137 The enterprise implementations are self-reported, and one is sourced through a conference talk rather than a first-party engineering publication.204,195,103 The indexing priority order is this framework’s judgment.
References cited in this section
16 of 243 · numbering matches the PDF
- 131Thibaud Gloaguen, Niels Mündler, Mark Müller, Veselin Raychev, and Martin Vechev, "Evaluating AGENTS.md: Are Repository-Level Context Files Helpful for Coding Agents?," arXiv:2602.11988, February 12, 2026, revised June 23, 2026. Preprint.arxiv.org/abs/2602.11988 ↗
- 132Jai Lal Lulla, Seyedmoein Mohsenimofidi, Matthias Galster, Jie M. Zhang, Sebastian Baltes, and Christoph Treude, "On the Impact of AGENTS.md Files on the Efficiency of AI Coding Agents," ICSE JAWs 2026. Task success rate explicitly not evaluated.
- 133Ali Arabat and Mohammed Sayagh, "Toward Instructions-as-Code: Understanding the Impact of Instruction Files on Agentic Pull Requests," arXiv:2606.13449. 15,549 agentic pull requests across 148 projects. Preprint.arxiv.org/abs/2606.13449. ↗
- 203Bowen Qin and Yi Xie, "Agent Retrieval Bench: Evaluating Repository Context Retrieval for Coding Agents," arXiv:2607.24882, July 2026. 427 samples across 25 repositories. Preprint.arxiv.org/abs/2607.24882 ↗
- 204Taj Shorter, "Inside Shopify's AI-First Engineering Playbook," Bessemer Venture Partners, April 1, 2026. Third-party interview; figures self-reported by Shopify with no methodology.
- 137Stefan Heule, Emily Jia, and Naman Jain, "Improving Agent with Semantic Search," Cursor Blog, November 6, 2025. Vendor-published, opposite architectural position to reference 136; each publishes evidence favoring its own approach.
- 136Anthropic, "Effective Context Engineering for AI Agents," September 29, 2025. Vendor position; no efficacy figures published for the three named long-horizon techniques.
- 195Spotify, "Portal MCP / Actions Registry," Backstage documentation. and Tyson Singer, "Introducing Xirp," Spotify Portal blog, August 10, 2026. Vendor-published; internal adoption figures self-reported.backstage.spotify.com/docs/portal/core-features-and-plugins/mcp/overview ↗
- 38GitClear, The Maintainability Gap: AI Code Quality in 2026, January 2026. 623 million analyzed changes, 2023–2026. Correlational; commits are not labeled by AI authorship; vendor-published.www.gitclear.com/the_ai_code_quality_maintainability_gap ↗
- 103Zohar Einy, "How Uber Built a Software Factory," Port newsletter, August 24, 2026. and Cameron McClellan, "How Uber Built the Enterprise AI Security Playbook," Speakeasy, May 28, 2026, https://www.speakeasy.com/blog/uber-enterprise-ai-playbook. Third-party summaries of conference talks, not first-party engineering posts; attribute to the talks.newsletter.port.io/p/how-uber-built-a-software-factory ↗
- 134Worawalan Chatlatanagulchai, Hao Li, Yutaro Kashiwa, et al., "Agent READMEs: An Empirical Study of Context Files for Agentic Coding," arXiv:2511.12884, November 17, 2025. 2,303 files from 1,925 repositories. Preprint.arxiv.org/abs/2511.12884 ↗
- 99Avishay Balter et al., "Security-Focused Guide for AI Code Assistant Instructions," OpenSSF Best Practices and AI/ML Working Groups, August 1, 2025.best.openssf.org/Security-Focused-Guide-for-AI-Code-Assistant-Instructions ↗
- 19CVE-2025-54135 ("CurXecute"), National Vulnerability Database, published August 4, 2025; research disclosure by Aim Security, August 1, 2025. CNA base score 8.5; NVD scores it 9.8. See also Tenable Research, "FAQ: CVE-2025-54135 and CVE-2025-54136, Vulnerabilities in Cursor," August 2025.
- 20CVE-2025-54136 ("MCPoison"), National Vulnerability Database, published August 1, 2025; research disclosure by Check Point Research, August 5, 2025. CNA base score 7.2; NVD scores it 8.8.
- 21Kudelski Security, "How We Exploited CodeRabbit: From a Simple PR to RCE and Write Access on 1M Repositories," August 19, 2025. Disclosed to vendor January 24, 2025; fix deployed January 30, 2025.
- 22Pillar Security, "New Vulnerability in GitHub Copilot and Cursor: How Hackers Can Weaponize Code Agents," March 18, 2025.