---
title: "Fix in risk order · Agent Wranglers"
url: https://agentwranglers.se/playbook/codebase-takeover/triage/fix-in-risk-order
id: TKO-7
level: Recommended
updated: 2026-10-22
tokens: 1016
licence: "CC BY 4.0"
licence_url: https://creativecommons.org/licenses/by/4.0/
---

# Fix in risk order

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-7
- Level: Recommended
- Chapter: [Triage](https://agentwranglers.se/playbook/codebase-takeover/triage.md)
- Rule: Work through an inherited codebase in a fixed order. Finish each step before structural changes start.
- Check: Every item on the work list carries a step number from 1 to 7. No change tagged step 6 or 7 merges while an item from steps 1 to 3 is open.
- How: A clean refactor does not help when the database is open to the internet. Step 1 covers accounts and secrets in [Take control of every account before touching the code](https://agentwranglers.se/playbook/codebase-takeover/triage/take-control-of-accounts.md) and [Rotate every secret the previous team could read](https://agentwranglers.se/playbook/codebase-takeover/triage/rotate-inherited-secrets.md). Step 2 is a backup, as [Take a backup and restore it before the first change](https://agentwranglers.se/playbook/codebase-takeover/triage/restore-before-first-change.md) says. Step 3 closes open security holes, such as [Check ownership on every record](https://agentwranglers.se/playbook/adversarial-testing/access-and-accounts/object-access.md) and [Keep secrets out of the browser](https://agentwranglers.se/playbook/adversarial-testing/data-and-secrets/secrets-out-of-browser.md). Step 4 adds error tracking and uptime alerts, as [Log, track errors and alert](https://agentwranglers.se/playbook/engineering/running-in-production/logs-and-alerts.md) says. Step 5 pins the critical paths with [characterization tests](https://agentwranglers.se/playbook/codebase-takeover/characterization-tests/pin-behaviour-first.md). Step 6 upgrades runtimes and dependencies that are out of support. Step 7 works on structure from the [debt register](https://agentwranglers.se/playbook/codebase-takeover/technical-debt/debt-register.md).

## Related rules

- TKO-1 [Take control of every account before touching the code](https://agentwranglers.se/playbook/codebase-takeover/triage/take-control-of-accounts.md) in Codebase takeover
- TKO-2 [Rotate every secret the previous team could read](https://agentwranglers.se/playbook/codebase-takeover/triage/rotate-inherited-secrets.md) in Codebase takeover
- TKO-3 [Take a backup and restore it before the first change](https://agentwranglers.se/playbook/codebase-takeover/triage/restore-before-first-change.md) in Codebase takeover
- SEC-17 [Check ownership on every record](https://agentwranglers.se/playbook/adversarial-testing/access-and-accounts/object-access.md) in Adversarial testing
- SEC-34 [Keep secrets out of the browser](https://agentwranglers.se/playbook/adversarial-testing/data-and-secrets/secrets-out-of-browser.md) in Adversarial testing
- ENG-23 [Log, track errors and alert](https://agentwranglers.se/playbook/engineering/running-in-production/logs-and-alerts.md) in Engineering
- TKO-8 [Pin today's behaviour before changing code](https://agentwranglers.se/playbook/codebase-takeover/characterization-tests/pin-behaviour-first.md) in Codebase takeover
- TKO-24 [Keep a debt register in the repository](https://agentwranglers.se/playbook/codebase-takeover/technical-debt/debt-register.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/fix-in-risk-order">Agent Wranglers codebase takeover playbook</a>`. In code you write, add a comment next to it with the same link.

- Previous: [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)
