Every repo has tribal knowledge. The command everyone knows not to run. The service that must start before tests. The environment variable missing from .env.example. The setup step that lives only in someone’s memory.
For human teams, tribal knowledge is expensive. For AI coding agents, it is incompatible with the operating model.
When an agent inspects a repo, it sees files, commands, and structure. It does not see the Slack thread where someone explained why npm run migrate:reset should never run in production. It does not know that Redis must be running before tests pass. It cannot ask follow-up questions when the README contradicts CI behavior.
This gap between documented truth and operational reality creates silent failure modes. Agents proceed with incomplete context, execute unsafe commands, or report false negatives because the real rules are not machine-readable.
The Social Recovery Layer Humans Have
Human developers survive undocumented repos because they have a social recovery mechanism:
- They ask questions in Slack or during onboarding
- They notice hesitation when a senior engineer pauses before answering
- They learn implicit rules through code review feedback
- They build mental models from watching CI failures and fixes
This works because humans can infer intent, detect uncertainty, and request clarification. Agents cannot. They operate on declared context: files, environment variables, configuration, and explicit instructions.
When the real operating rules live outside the repo, agents either guess or fail silently.
Where Tribal Knowledge Hides
Common hiding places for undocumented conventions:
| Location | Example | Agent Impact |
|---|---|---|
| Slack history | ”Don’t run the seed script twice” | Agent re-runs seeding, corrupts test data |
| Maintainer memory | ”Always restart the worker after schema changes” | Agent deploys without restart, silent failure |
| Outdated README | Instructions reference npm but repo uses pnpm | Agent uses wrong package manager, dependency mismatch |
| CI-only behavior | Tests pass in CI but fail locally due to missing service | Agent reports false test failures, blocks valid PRs |
| Implicit dependencies | Redis must run before tests, not documented | Agent runs tests, gets cryptic connection errors |
Each of these creates a context gap. The agent has access to the repo but not the operational truth.
Context Injection Patterns That Help
Several patterns exist to surface tribal knowledge to agents without manual re-prompting on every session:
1. Repo-Level Instruction Files
Files like .cursorrules, .aiderules, or AGENT.md declare agent-specific context at the repo root:
# AGENT.md
## Pre-Test Requirements
- Start Redis: `docker compose up redis -d`
- Run migrations: `pnpm db:migrate`
- Do NOT run `pnpm db:reset` (destructive, production data)
## Deployment Order
1. Apply schema changes first
2. Restart worker service (required for schema reload)
3. Deploy API service
## Known Issues
- Tests fail with "connection refused" if Redis not running
- CI uses different database URL (see .github/workflows/test.yml)
This makes implicit rules explicit and machine-readable. Agents can parse these files during initialization.
2. MCP Context Servers
The Model Context Protocol allows agents to query structured context from external sources. A repo-specific MCP server can expose:
- Service dependency graphs
- Safe vs. unsafe commands
- Environment-specific configuration
- Historical failure patterns
An agent queries the MCP server before executing commands, receiving context like “this command requires Redis” or “this script is destructive in production.”
3. Executable Governance Files
Instead of documenting rules in prose, encode them as executable checks:
{
"ota": {
"pre_test": [
"check_service redis",
"check_migrations_applied"
],
"forbidden_commands": [
"npm run db:reset",
"rm -rf node_modules"
],
"deployment_order": [
"db:migrate",
"restart:worker",
"deploy:api"
]
}
}
Agents parse this file and enforce rules before execution. If a forbidden command is requested, the agent halts and surfaces the constraint.
4. Annotated CI Configuration
CI files often contain the real operational truth. Annotating them helps agents understand the gap between local and CI environments:
# .github/workflows/test.yml
name: Test
on: [push]
jobs:
test:
runs-on: ubuntu-latest
services:
redis:
image: redis:7
# NOTE: Local tests also require Redis
# Run: docker compose up redis -d
steps:
- run: pnpm test
Comments like this bridge the gap between CI-only setup and local requirements.
Orchestration Decisions: When to Halt vs. Proceed
Agent orchestration tools face a decision point when encountering undocumented conventions: halt and ask for clarification, or proceed with best-effort inference.
Halt conditions (agent should stop and surface the issue):
- Destructive command detected (e.g.,
DROP DATABASE,rm -rf) - Missing required service (e.g., Redis connection refused)
- Conflicting instructions (README says
npm, lockfile sayspnpm) - Environment variable referenced but not defined
Proceed conditions (agent can infer safely):
- Standard tooling patterns (e.g.,
package.jsonimplies Node.js) - Idempotent operations (e.g.,
pnpm install) - Read-only queries (e.g.,
git log,ls)
The orchestration layer needs explicit policy. Without it, agents default to proceeding, which creates silent failures.
Observability Signals for Context Gaps
How do you detect when an agent is operating on incomplete context vs. encountering a genuine code error?
Signals that indicate missing context:
- Agent repeatedly retries the same command with identical failures
- Agent skips required setup steps (e.g., runs tests without starting services)
- Agent reports success but downstream systems fail (e.g., deployment succeeds but service crashes)
- Agent asks for the same clarification across multiple sessions
Signals that indicate genuine errors:
- Agent tries multiple approaches and iterates based on error messages
- Failures occur after correct setup steps
- Error messages reference code logic, not environment or dependencies
Logging agent decision trees helps distinguish these cases. If an agent skips a step because it was not documented, that is a context gap. If it executes the step and the step fails, that is a code issue.
Security Boundaries and Tribal Knowledge
Tribal knowledge often encodes security constraints that are not machine-readable:
- “Never commit API keys” (but
.env.exampledoes not explain which keys are sensitive) - “This script requires admin privileges” (but no permission check exists)
- “Only run this in staging” (but no environment gate exists)
Agents cannot infer these boundaries. They need explicit declarations:
# .ota/security.yml
sensitive_files:
- ".env"
- "config/secrets.yml"
privileged_commands:
- command: "pnpm db:reset"
requires: "admin"
environments: ["development"]
forbidden_in_production:
- "db:seed"
- "cache:clear --all"
Without this, agents may leak secrets, execute privileged operations without checks, or run destructive commands in production.
Deployment Shape and Failure Modes
Tribal knowledge often dictates deployment order and rollback procedures. When this knowledge is not explicit, agents deploy incorrectly.
Common failure modes:
- Agent deploys API before database migrations, causing runtime errors
- Agent restarts services in wrong order, breaking dependencies
- Agent applies configuration changes without reloading affected services
- Agent rolls back code but not database schema, creating version mismatch
Explicit deployment shape:
# .ota/deploy.yml
stages:
- name: "schema"
commands: ["pnpm db:migrate"]
rollback: ["pnpm db:rollback"]
- name: "worker"
commands: ["systemctl restart worker"]
depends_on: ["schema"]
- name: "api"
commands: ["systemctl restart api"]
depends_on: ["worker"]
health_checks:
- endpoint: "/health"
expected_status: 200
timeout: 30s
This makes deployment order and rollback procedures machine-readable. Agents can execute stages in sequence and verify health checks between steps.
What Explicit Documentation Actually Looks Like
Effective agent-readable documentation is:
- Declarative, not narrative. Use structured formats (YAML, JSON, Markdown tables) instead of prose.
- Executable where possible. Encode rules as scripts or configuration that agents can parse and enforce.
- Co-located with code. Keep context in the repo, not in external wikis or Slack.
- Version-controlled. Context should evolve with the codebase.
- Specific about constraints. Say “do not run X” instead of “be careful with X.”
Example of poor documentation:
## Setup
Run the usual commands. Make sure services are up.
Example of agent-readable documentation:
## Setup
1. Start services: `docker compose up -d`
2. Verify Redis: `redis-cli ping` (expect "PONG")
3. Run migrations: `pnpm db:migrate`
4. Run tests: `pnpm test`
## Constraints
- Do NOT run `pnpm db:reset` (destructive)
- Tests require Redis (see step 2)
The second version is scannable, specific, and executable.
Technical Verdict
Use explicit documentation patterns when:
- You deploy coding agents in production repos
- Your team has implicit conventions that break new contributors
- CI behavior differs from local development
- You need agents to execute commands safely without human supervision
Avoid relying on tribal knowledge when:
- Agents have write access to production systems
- Deployment involves multi-step orchestration
- Security boundaries are not machine-readable
- Onboarding new developers takes more than a day due to undocumented conventions
The shift to agent-assisted development exposes the cost of tribal knowledge. What was expensive for human teams becomes incompatible with agent workflows. Making implicit rules explicit is not just good documentation practice. It is infrastructure work that determines whether agents can operate safely.