Claude Code Company Context: Give AI Real Knowledge of Your Codebase

9 min read

Claude Code and Codex produce better code when they understand your architecture, decisions, and docs. Here's how engineering teams build that context systematically.

Most engineering teams using Claude Code hit the same wall: the AI writes syntactically correct code that misses the point. It doesn't know your service boundaries, your naming conventions, the reason you chose that database, or why that workaround exists in auth.ts. Every session starts cold.

Giving Claude Code genuine company context — not just a file dump, but structured knowledge about your codebase, docs, and decisions — is the difference between an AI that generates plausible-looking code and one that generates code you can actually ship.

Why Claude Code Loses Context (and Why That's Your Problem to Solve)

Claude Code operates within a context window. When a session ends, that window closes. The next session knows nothing about the architectural decision you explained yesterday, the API contract you settled on last sprint, or the incident that led to the retry logic in your queue worker.

A widely-cited thread on r/ClaudeCode captures the pattern engineers keep rediscovering: maintain a CLAUDE.md file updated after every major change, keep it concise, and start a fresh context for each task rather than letting a single session sprawl. That's good hygiene, but it's still manual — someone has to remember to update the file, and it doesn't pull in the living context from Slack threads, Notion docs, or your ticketing system.

Anthropic's own internal report on how their teams use Claude Code shows that the highest-leverage use cases — Kubernetes debugging, data infrastructure automation, security engineering — all share one trait: the team fed Claude Code rich, specific context (screenshots, logs, documentation) rather than relying on it to infer from code alone. The AI followed menu-by-menu through Google Cloud's UI to diagnose pod IP exhaustion, because someone gave it the right starting information.

Context quality determines output quality. That's the whole game.

The Three Layers of Context Claude Code Actually Needs

Before building a system, it helps to be precise about what "context" means for a coding AI. There are three distinct layers:

1. Structural context — How the codebase is organized. What services exist, what they own, how they communicate, what's deprecated. This is mostly answerable from the repo itself if you surface it correctly.

2. Decision context — Why things are the way they are. The ADR (architecture decision record) explaining why you're on Postgres instead of MongoDB. The Slack thread where you agreed on the error-handling contract. The comment in the PR that explains the edge case. This lives scattered across tools.

3. Current state context — What's true right now. Open tickets, recent incidents, in-progress migrations, the feature flag that's half-rolled-out. This changes daily and is almost never in the repo.

Most teams handle layer one reasonably well. Layers two and three are where sessions go wrong.

Building a CLAUDE.md That Actually Works

The CLAUDE.md file (or AGENTS.md for Codex) is Claude Code's persistent memory for a project. It loads automatically at session start. Treat it like an onboarding doc for a senior engineer who's smart but knows nothing about your company.

A useful CLAUDE.md includes:

  • Architecture overview — 5-10 sentences on the system topology. Services, their responsibilities, how they talk to each other.
  • Tech stack and versions — Don't make Claude guess. Specify the framework, ORM, auth library, and any non-obvious dependencies.
  • Naming and style conventions — If your team uses snake_case for database columns and camelCase for API responses, say so. If you have a pattern for error types, document it.
  • What not to touch — Legacy modules, third-party integrations with known quirks, anything that breaks in non-obvious ways.
  • Key decisions — 3-5 bullet points on choices that would surprise an outsider. "We use optimistic locking instead of transactions in the inventory service because of X."
  • Links to living docs — Point to your Notion runbooks, your internal API spec, your incident post-mortems.

Keep it under 500 lines. As practitioners on r/ClaudeAI note, a well-structured CLAUDE.md can feed into PRD prompts and validation workflows — it becomes the source of truth that other context-engineering artifacts reference.

Update it after every architectural change, not every PR. Assign ownership — if nobody owns it, it rots.

Using CLAUDE.md Across Both Claude Code and Codex

If your team uses both Claude Code and OpenAI's Codex, the same project context file works for both. Practitioners have documented five-minute workflows for reusing Claude Code project configurations in Codex — the core insight being that architectural decisions and debugging context from past sessions are too valuable to leave siloed in one tool.

The practical approach:

  1. Maintain a single CLAUDE.md / AGENTS.md at the repo root.
  2. Store session summaries (decisions made, approaches rejected, context established) in a /docs/ai-sessions/ folder with dates.
  3. Reference those summaries in new sessions with either tool: "See /docs/ai-sessions/2025-06-auth-refactor.md for the decisions made on the auth service."

This gives you a lightweight audit trail and means neither Claude Code nor Codex starts completely cold on a long-running project.

Surfacing Decision Context from Where It Actually Lives

The hard part isn't writing CLAUDE.md — it's pulling in the context that lives outside the repo. Your architecture decisions are in Notion. Your API contracts were settled in a Slack thread. Your incident learnings are in a Google Doc nobody remembers the URL of.

Manually copying this into CLAUDE.md is brittle. It goes stale. Someone forgets to update it after the migration.

The more durable approach is to connect your AI tools to the systems where context actually lives — and keep that connection current. This is exactly what Gyld's business context layer does: it ingests your company's data from Slack, Notion, Google Drive, HubSpot, and other tools into a per-company knowledge base, then exposes that knowledge as MCP servers that Claude Code, Codex, Cursor, or any other AI agent can query directly.

Instead of manually maintaining a static document, Claude Code can ask "what did we decide about the auth service architecture?" and get a sourced, current answer drawn from your actual Notion docs and Slack history — with citations back to the original source so you can verify it.

MCP Servers: The Structural Solution to Context Loss

Model Context Protocol (MCP) is the standard that lets AI agents query external systems for context at inference time. Rather than pre-loading everything into a prompt (which hits token limits fast) or fine-tuning a model on your codebase (expensive, goes stale), MCP lets Claude Code pull exactly the context it needs, when it needs it.

For an engineering team, useful MCP servers include:

Context typeWhere it livesMCP approach
Architecture decisionsNotion, ConfluenceIndex docs; query by topic
API contractsGoogle Drive, internal wikisIndex and surface on request
Incident historySlack channels, post-mortemsIndex by service name
Current ticketsLinear, Jira, GitHub IssuesQuery open issues by label
Code conventionsRepo + CLAUDE.mdFile-based, loaded at session start

Gyld exposes your connected apps as MCP servers with permission controls — you choose what gets indexed, who can see what, and the knowledge stays current without a RAG pipeline to maintain. Compare how this differs from building your own RAG setup if you're evaluating the build-vs-buy question.

A Practical Context Engineering Workflow for Engineering Teams

Here's a workflow you can implement this week:

Step 1: Write the CLAUDE.md once, properly.
Spend two hours with your tech lead. Cover architecture, decisions, conventions, and no-go zones. Commit it to the repo root.

Step 2: Create a session summary template.
After any Claude Code session that produces a significant decision or approach, save a summary: what was tried, what was decided, why. Store in /docs/ai-sessions/YYYY-MM-DD-topic.md.

Step 3: Reference session history in new tasks.
Open new sessions with: "Before starting, read CLAUDE.md and the relevant files in /docs/ai-sessions/." This takes 30 seconds and prevents relitigating settled decisions.

Step 4: Connect your external knowledge sources.
Identify where your real decision context lives — Notion, Slack, Google Drive. Either build a process to pull key decisions into CLAUDE.md weekly, or connect those sources via MCP so Claude Code can query them directly.

Step 5: Assign context ownership.
Someone on the team owns CLAUDE.md. It's updated after architectural changes, not left to drift. Treat it like a living document, not a one-time artifact.

Takeaways

  • A well-maintained CLAUDE.md is the minimum viable context layer — cover architecture, decisions, conventions, and anti-patterns.
  • Session summaries stored in the repo give Claude Code and Codex a lightweight memory across sessions and across tools.
  • The real context gap is decision and current-state knowledge that lives in Slack, Notion, and Google Drive — MCP servers that connect those sources solve this structurally, without manual copying.

If your team wants Claude Code to understand not just your code but the business context behind it — the decisions, the docs, the current state — start building your company brain with Gyld and connect the tools where your knowledge actually lives.

Frequently asked questions

What is CLAUDE.md and how does it help Claude Code?

CLAUDE.md is a markdown file placed at the root of your project that Claude Code loads automatically at the start of each session. It acts as persistent context — covering architecture, conventions, key decisions, and anything else Claude Code needs to understand your project. Without it, every session starts cold.

Can I use the same context file for both Claude Code and Codex?

Yes. Both tools support project-level instruction files (CLAUDE.md for Claude Code, AGENTS.md for Codex). Maintaining a single source of truth and referencing it in both tools is more reliable than keeping separate files that drift apart.

What's the difference between loading context in a prompt vs. using an MCP server?

Loading context in a prompt is fast but hits token limits quickly and requires you to know in advance what context is needed. An MCP server lets the AI query for context at inference time — pulling only what's relevant for the current task from a larger knowledge base. For large codebases or multi-tool knowledge, MCP scales better.

How do I keep CLAUDE.md from going stale?

Assign explicit ownership to one person on the team. Update it after architectural decisions, not after every PR. Keep it under 500 lines — if it's too long, nobody reads it and it stops being maintained. For context that changes frequently (current tickets, recent incidents), link out to living sources rather than duplicating them.

How is Gyld different from just building a RAG pipeline over my docs?

A RAG pipeline requires you to build and maintain the ingestion, chunking, embedding, and retrieval infrastructure yourself — and it goes stale whenever your source docs change. Gyld connects to your existing apps, keeps the knowledge base current automatically, applies permission controls, and exposes everything as MCP servers your AI tools can query directly. See the full comparison.

Curtis Rosenvall

Give your AI your company's brain.

Your email, Slack, CRM, and docs — one company brain any AI can use, every answer source-cited.

Free plan · no card · first answer in ~5 minutes