---
name: paginated_config_replace_guard
title: "Paginated Config Replace Guard"
description: "Replace a service full configuration safely by fetching every page of the current set, backing it up and diffing key names before and after, so a truncated list can never delete live settings."
version: 1.0.0
author: Script Master Labs LLC
license: MIT
source: https://scriptmasterlabs.com/hive402-skills/paginated_config_replace_guard/SKILL.md
registry: HIVE402 Skills (https://scriptmasterlabs.com/hive402-skills)
---

# Paginated Config Replace Guard

## Fetch the complete current set first

- Fetch the current configuration with the largest page size the API allows and follow every pagination cursor until a page returns no continuation.

- Count the keys in the fetched set and state that count before building any replacement payload.

- Treat a round default count such as 20 as a truncation warning and keep fetching instead of assuming the first page is the whole set.

- Apply the same complete fetch rule to any list endpoint whose result will feed a full replace, not only to environment variables.

## Back up and diff before replacing

- Save the complete fetched set to a local backup file with owner-only permissions before any replace call.

- Build the replacement from the backed up complete set plus the intended change, never from a partial fetch or from a helper whose list command truncates.

- Diff the key names in the replacement against the backup and name every key that would disappear before sending it.

- Stop and report instead of sending when a key would disappear and the task did not explicitly call for its removal.

## Verify after the replace

- Fetch the configuration again with the same complete pagination and count the keys.

- Compare the after key names with the intended final set and report both counts side by side.

- Restore from the backup file at once when a key the task meant to keep is missing after the replace.

- Report the service as updated only after the read back matches the intended set.

## Alternatives for better results

- Prefer a targeted update of only the changed keys over a full replace whenever the API supports one, so the rest of the set is never at risk.

- Read the provider status page before debugging a deploy that fails right after a config change, so a platform outage is not mistaken for a bad replacement.


---

## From Script Master Labs

This skill is listed in [HIVE402 Skills](https://scriptmasterlabs.com/hive402-skills) —
every skill there passed a verification gate before listing: parsed, safety-scanned,
provenance recorded, self-contained. Skills, probed before listed.

Script Master Labs also runs [HIVE402](https://hive402.scriptmasterlabs.com), the
payability-probed catalog of 132 paid agent APIs, [OMNIGATE](https://scriptmasterlabs.com/omnigate-facilitator),
the x402 gateway those payments settle through, and the free
[x402 Starter Kit](https://scriptmasterlabs.com/x402-kit).
