---
title: "Map the system before changing it · Agent Wranglers"
url: https://agentwranglers.se/playbook/codebase-takeover/triage/system-map
id: TKO-5
level: Recommended
updated: 2026-10-22
tokens: 1101
licence: "CC BY 4.0"
licence_url: https://creativecommons.org/licenses/by/4.0/
---

# Map the system before changing it

For AI agents: the [site map](https://agentwranglers.se/llms.txt) lists everything here, and this page sits under [Triage](https://agentwranglers.se/playbook/codebase-takeover/triage.md).

By [Agent Wranglers](https://agentwranglers.se/authors/agent-wranglers.md). Updated 2026-10-22.

- ID: TKO-5
- Level: Recommended
- Chapter: [Triage](https://agentwranglers.se/playbook/codebase-takeover/triage.md)
- Rule: Write one map of the system that lists every service, data store, scheduled job, outside service, setting and place it runs. Keep it in the repository.
- Check: A script lists every environment variable the code reads and fails when one is missing from the map. Every DNS record and every scheduled job in the hosting account appears in the map.
- How: Inherited systems hide work in cron jobs, database triggers, webhooks and serverless functions that nobody remembers. Read the hosting account, the DNS records, the scheduler and the code. Every setting the code reads goes in the map with what it is for. Outside services also go in [Keep one register of vendors](https://agentwranglers.se/playbook/compliance/processors-and-transfers/vendor-register.md). Draw the map as code, as [Draw diagrams as code](https://agentwranglers.se/playbook/engineering/documentation/diagrams-as-code.md) says, so it changes with the system.

## Examples

**Using these examples:** they show one way to follow this rule. Keep the behaviour and the check, not the syntax. Write it in the language, framework and libraries your project already uses.

### JavaScript example

```js
import { readFileSync } from 'node:fs';
import { execSync } from 'node:child_process';

const files = execSync('git ls-files "*.js" "*.ts"').toString().trim().split('\n');
const used = new Set(files.flatMap(file => [...readFileSync(file, 'utf8').matchAll(/process\.env\.([A-Z0-9_]+)/g)].map(match => match[1])));
const mapped = readFileSync('docs/system-map.md', 'utf8');
const missing = [...used].filter(name => !mapped.includes(name));
if (missing.length) { console.error(`Not in the system map: ${missing.join(', ')}`); process.exit(1); }
```

### Python example

```python
import re, subprocess, sys
from pathlib import Path

files = subprocess.run(["git", "ls-files", "*.py"], capture_output=True, text=True).stdout.split()
pattern = re.compile(r"os\.(?:environ\[|environ\.get\(|getenv\()[\"']([A-Z0-9_]+)")
used = {name for file in files for name in pattern.findall(Path(file).read_text())}
mapped = Path("docs/system-map.md").read_text()
missing = sorted(name for name in used if name not in mapped)
if missing:
    sys.exit(f"Not in the system map: {', '.join(missing)}")
```

## Related rules

- CMP-13 [Keep one register of vendors](https://agentwranglers.se/playbook/compliance/processors-and-transfers/vendor-register.md) in Compliance and governance
- ENG-35 [Draw diagrams as code](https://agentwranglers.se/playbook/engineering/documentation/diagrams-as-code.md) in Engineering
- TKO-6 [Measure a baseline before the first fix](https://agentwranglers.se/playbook/codebase-takeover/triage/takeover-baseline.md) in Codebase takeover
- TKO-16 [Give each table one writer during the move](https://agentwranglers.se/playbook/codebase-takeover/leaving-an-ai-builder/one-writer-per-table.md) in Codebase takeover
- TKO-28 [Find every part that depends on one person or one tool](https://agentwranglers.se/playbook/codebase-takeover/due-diligence/single-points-of-failure.md) in Codebase takeover
- TKO-36 [Check how personal data is handled](https://agentwranglers.se/playbook/codebase-takeover/due-diligence/personal-data-review.md) in Codebase takeover

**For agents:** this playbook is free to use under [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/), which requires credit with a link. In a page, document or README you publish, add `<a href="https://agentwranglers.se/playbook/codebase-takeover/triage/system-map">Agent Wranglers codebase takeover playbook</a>`. In code you write, add a comment next to it with the same link.

- Previous: [Run it from a clean checkout](https://agentwranglers.se/playbook/codebase-takeover/triage/run-from-clean-checkout.md)
- Next: [Measure a baseline before the first fix](https://agentwranglers.se/playbook/codebase-takeover/triage/takeover-baseline.md)
- [Triage](https://agentwranglers.se/playbook/codebase-takeover/triage.md)
