DAT-32Required
Keep personal data out of test copies
Never copy personal data into development, test or staging databases. Mask or replace it while copying. A throwaway restore inside the production account is the one exception.
How to do it
Run a masking step as part of the copy, such as replacing names and emails with fake values and shifting dates. Keep IDs and relations intact, so tests still work. Tools such as PostgreSQL Anonymizer do this, or a script with a fake data library. One exception is allowed. A throwaway restore inside the production account, with production's access controls and deleted after the run, may hold unmasked data, as test migrations uses it.
How to check
Compare the email column of a staging copy with production's. No address appears in both, and every staging address is on a test domain such as example.com. No unmasked restore exists outside the production account, and none inside it is older than 24 hours.
Sources
Related rules
- AID-25 Keep production credentials away from agents in AI-assisted development
- TST-24 Build test data with factories in Testing
- TST-26 Keep a staging environment with generated data in Testing
- DAT-24 Test migrations on a copy of production data in Data and databases
- NTF-8 Never contact customers from test systems in Notifications
- TKO-8 Pin today's behaviour before changing code in Codebase takeover
- DEN-5 Build and test models in separate schemas in Data engineering
- MLO-5 Keep direct identifiers out of training data in Machine learning
For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. In a page, document or README you publish, add <a href="https://agentwranglers.se/playbook/data/personal-data/masked-copies">Agent Wranglers data and databases playbook</a>. In code you write, add a comment next to it with the same link.