---
title: "Compare environments with the same release · Agent Wranglers"
url: https://agentwranglers.se/playbook/testing/output-comparison/compare-environments
id: TST-46
level: Optional
updated: 2026-10-22
tokens: 875
licence: "CC BY 4.0"
licence_url: https://creativecommons.org/licenses/by/4.0/
---

# Compare environments with the same release

For AI agents: the [site map](https://agentwranglers.se/llms.txt) lists everything here, and this page sits under [Output comparison](https://agentwranglers.se/playbook/testing/output-comparison.md).

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

- ID: TST-46
- Level: Optional
- Chapter: [Output comparison](https://agentwranglers.se/playbook/testing/output-comparison.md)
- Rule: The same release on staging and production gives the same bytes at every address. The only exceptions are a named list of environment values.
- Check: After each deploy to production, a job compares both snapshots. It fails on any difference that the list of environment values does not explain. The list holds at most 5 values.
- How: Take a [live snapshot](https://agentwranglers.se/playbook/testing/output-comparison/compare-live-before-and-after.md) of both environments with the same address paths. Replace the host name and each listed environment value with a marker before hashing, for example the base address and the analytics key. A difference that remains means one environment runs other code, other settings or other data. This is the same test as a [staging copy that matches production](https://agentwranglers.se/playbook/testing/test-data-and-environments/production-like-staging.md), measured in bytes.

## 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
const ENVIRONMENT_VALUES = { 'https://staging.example.com': 'BASE_URL', 'https://example.com': 'BASE_URL', 'UA-STAGING': 'ANALYTICS_KEY', 'UA-LIVE': 'ANALYTICS_KEY' }

export const normalised = body => Object.entries(ENVIRONMENT_VALUES)
  .sort(([a], [b]) => b.length - a.length)
  .reduce((text, [value, marker]) => text.replaceAll(value, marker), body)
```

### Python example

```python
ENVIRONMENT_VALUES = {"https://staging.example.com": "BASE_URL", "https://example.com": "BASE_URL",
                      "UA-STAGING": "ANALYTICS_KEY", "UA-LIVE": "ANALYTICS_KEY"}

def normalised(body):
    for value in sorted(ENVIRONMENT_VALUES, key=len, reverse=True):
        body = body.replace(value, ENVIRONMENT_VALUES[value])
    return body
```

## Related rules

- TST-45 [Compare the live system before and after each deploy](https://agentwranglers.se/playbook/testing/output-comparison/compare-live-before-and-after.md) in Testing
- TST-26 [Keep a staging copy with fake data](https://agentwranglers.se/playbook/testing/test-data-and-environments/production-like-staging.md) in Testing

**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/testing/output-comparison/compare-environments">Agent Wranglers testing playbook</a>`. In code you write, add a comment next to it with the same link.

- Previous: [Compare the live system before and after each deploy](https://agentwranglers.se/playbook/testing/output-comparison/compare-live-before-and-after.md)
- Next: [Keep the previous release's manifest](https://agentwranglers.se/playbook/testing/output-comparison/keep-previous-manifest.md)
- [Output comparison](https://agentwranglers.se/playbook/testing/output-comparison.md)
