---
title: "Compare the live system before and after · Agent Wranglers"
url: https://agentwranglers.se/playbook/testing/output-comparison/compare-live-before-and-after
updated: 2026-10-21
licence: "All rights reserved"
---

# Compare the live system before and after each deploy

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

- Level: Recommended
- Chapter: [Output comparison](https://agentwranglers.se/playbook/testing/output-comparison)
- Rule: Before and after each deploy, fetch every public address with fixed request headers. Record status, key headers and a body hash. The live diff must match the local diff.
- How: Build the address list from the sitemap and add the machine files. These include `robots.txt`, feeds, sitemaps, `/.well-known/` files, API endpoints and known redirects. Send the same `Accept`, `Accept-Encoding` and `User-Agent` on every request, and never follow redirects. Record content-type, cache-control, location and the security headers. Apply the [masks](https://agentwranglers.se/playbook/testing/output-comparison/narrow-masks) before hashing bodies. This runs next to the [smoke test](https://agentwranglers.se/playbook/testing/end-to-end-and-browser-tests/smoke-test-every-deploy) and the [rollback](https://agentwranglers.se/playbook/engineering/build-test-and-deploy/atomic-deploys-with-rollback).
- Check: After each deploy, a job compares the two snapshots against the [expected paths](https://agentwranglers.se/playbook/testing/output-comparison/expected-differences). One address that changed and is not listed raises an alert or rolls the deploy back.

## 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 HEADERS = ['content-type', 'cache-control', 'location', 'content-security-policy', 'strict-transport-security']
const REQUEST = { redirect: 'manual', headers: { 'accept': '*/*', 'accept-encoding': 'identity', 'user-agent': 'output-compare/1' } }

async function snapshot(urls) {
  const entries = []
  for (const url of urls) {
    const response = await fetch(url, REQUEST)
    const body = new Uint8Array(await response.arrayBuffer())
    const digest = Buffer.from(await crypto.subtle.digest('SHA-256', body)).toString('hex')
    entries.push({ url, status: response.status, headers: Object.fromEntries(HEADERS.map(name => [name, response.headers.get(name)])), sha256: digest })
  }
  return entries
}

const urls = ['https://example.com/robots.txt', 'https://example.com/feed.xml', 'https://example.com/old-pricing']
console.log(JSON.stringify(await snapshot(urls), null, 2))
```

### Python example

```python
import hashlib, json, urllib.error, urllib.request

HEADERS = ["content-type", "cache-control", "location", "content-security-policy", "strict-transport-security"]
REQUEST_HEADERS = {"Accept": "*/*", "Accept-Encoding": "identity", "User-Agent": "output-compare/1"}

class NoRedirect(urllib.request.HTTPRedirectHandler):
    def redirect_request(self, *args):
        return None

opener = urllib.request.build_opener(NoRedirect)

def fetch(url):
    try:
        response = opener.open(urllib.request.Request(url, headers=REQUEST_HEADERS))
    except urllib.error.HTTPError as error:
        response = error
    body = response.read()
    return {"url": url, "status": response.status,
            "headers": {name: response.headers.get(name) for name in HEADERS},
            "sha256": hashlib.sha256(body).hexdigest()}

urls = ["https://example.com/robots.txt", "https://example.com/feed.xml", "https://example.com/old-pricing"]
print(json.dumps([fetch(u) for u in urls], indent=2))
```

## Related rules

- [Write a manifest of the whole output](https://agentwranglers.se/playbook/testing/output-comparison/output-manifest) in Testing
- [Mask volatile parts narrowly](https://agentwranglers.se/playbook/testing/output-comparison/narrow-masks) in Testing
- [Smoke test every deploy](https://agentwranglers.se/playbook/testing/end-to-end-and-browser-tests/smoke-test-every-deploy) in Testing
- [Deploy in one step and roll back by itself](https://agentwranglers.se/playbook/engineering/build-test-and-deploy/atomic-deploys-with-rollback) in Engineering
- [Explain every difference in an intended change](https://agentwranglers.se/playbook/testing/output-comparison/expected-differences) in Testing
- [Compare environments with the same release](https://agentwranglers.se/playbook/testing/output-comparison/compare-environments) 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-live-before-and-after">Agent Wranglers testing playbook</a>`. In code you write, add a comment next to it with the same link.

- Previous: [Mask volatile parts narrowly](https://agentwranglers.se/playbook/testing/output-comparison/narrow-masks)
- Next: [Compare environments with the same release](https://agentwranglers.se/playbook/testing/output-comparison/compare-environments)
- [Output comparison](https://agentwranglers.se/playbook/testing/output-comparison)
