test-data
Skill1 starsChanged 7 months agoMITView on GitHub
Scaffold an Apex `TestDataFactory` for an sObject using its required fields and project-context defaults. Outputs a class with `make<Object>()`, `make<Object>(overrides)`, and `make<Object>List(count, overrides)` methods, plus a sensible defaults map. Saves the most tedious part of writing tests.
3 other projects use a version of this.
Adopted by
Most recently taken up by
- alexpalexpinne/qa-toolkittheir own version, first seen Nov 8, 2026
- DataWithBaraa/claude-code-data-engineering-skillstheir own version, first seen Nov 1, 2026
- katalon-labs/true-skillstheir own version, first seen Jun 23, 2026
Other versions3 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 3
- DataWithBaraa/claude-code-data-engineering-skills★ 84same name
- katalon-labs/true-skills★ 10same name
- alexpalexpinne/qa-toolkit★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository53 other files it gives its agents.
- templates/CLAUDE.mdCLAUDE.md
- adrSkill
- agent-deploySkill
- agent-discoverSkill
- agent-eval-trendSkill
- agent-exchange-listSkill
- agent-specSkill
- agent-testSkill
- agent-vs-flow-vs-apexSkill
- before-vs-after-triggerSkill
- code-reviewSkill
- complexitySkill
- coverage-trendSkill
- dead-codeSkill
- dependency-graphSkill
- deploySkill
- destructive-changesSkill
- diff-deploySkill
- erdSkill
- field-impactSkill
- flaky-test-finderSkill
- flow-auditSkill
- flow-vs-apexSkill
- fls-auditSkill
- gateway-configSkill
- generate-docsSkill
- limit-usageSkill
- lwc-vs-reactSkill
- mcp-tool-vs-restSkill
- notifySkill
- onboardSkill
- org-diffSkill
- org-exploreSkill
- package-versionSkill
- pattern-packSkill
- perf-reviewSkill
- permset-auditSkill
- pr-prepareSkill
- queueable-vs-batchSkill
- quick-deploySkill
- react-initSkill
- release-notesSkill
- scratch-orgSkill
- security-scanSkill
- sequence-diagramSkill
- sf-initSkill
- sharing-reviewSkill
- slack-agentSkill
- soql-analyzerSkill
- test-coverageSkill
- test-planSkill
- trust-evalSkill
- trust-layer-auditSkill
The file
We split this skill into the rules it gives an agent
5 rules. 0 are common, 1 is distinctive, and 4 are very specific to this project.
0
Common
Most of the 3 edited versions we read keep these.
1
Distinctive
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 31
Prefer the org cache (${CLAUDE_PLUGIN_DATA}/argo/org-cache/<org>.json) — it has the full describe.
- Very specific: line 144
When multiple objects are given, generate factories in dependency order (parent before child).
- Very specific: line 148
Write ${APEX_SRC}/<ClassName>.cls and <ClassName>.cls-meta.xml.
- Very specific: line 156
If --update was passed and the factory already exists, append new methods (do not duplicate.
- Distinctive: line 168
Don't hardcode IDs: Always derive lookup values from another factory call
“Common” is measured: kept by at least 6 in 10 of the 3 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
You are scaffolding an Apex TestDataFactory for one or more sObjects. The factory provides a stable way to build valid test records (all required fields populated) with optional per-test overrides.
Read Project Config First
source "${CLAUDE_PLUGIN_ROOT}/hooks/lib/config.sh"
APEX_SRC="$(sf_config_get '.paths.apexSource' "$ENV")"
TEST_SUFFIX="$(sf_config_get '.naming.apex.testSuffix' "$ENV")" # default: Test
ORG="$(sf_config_get '.platform.defaultTargetOrg' "$ENV")"Input
$ARGUMENTS: required.
<Object>— generate a factory method for one sObject (e.g.,Account)<Object1> <Object2> ...— multiple objects in one factory class--class-name <Name>— override factory class name (defaultTestDataFactory)--out <path>— write to a specific path (default${APEX_SRC}/TestDataFactory.cls)--update— append methods to an existing factory rather than replacing
Steps
1. Resolve required fields per sObject
Prefer the org cache (${CLAUDE_PLUGIN_DATA}/argo/org-cache/<org>.json) — it has the full describe. If absent, fall back to live sf_cli_describe <Object> <ORG>.
For each field, capture:
name(API name)type(string, picklist, reference, currency, date, etc.)nillable— required iffalsedefaultValueFormula— if set, no need to populatereferenceTo— for lookups, the target sObjectpicklistValues— first active value as defaultlength— for strings, set test value to a stable short value
2. Generate the factory class
@isTest
public class TestDataFactory {
// ---------- Account ------------------------------------------------------
public static Account makeAccount() {
return makeAccount(new Map<String,Object>());
}
public static Account makeAccount(Map<String, Object> overrides) {
Account a = new Account(
Name = 'Test Account ' + uniq()
// (other required fields populated here)
);
applyOverrides(a, overrides);
insert a;
return a;
}
public static List<Account> makeAccountList(Integer count, Map<String, Object> overrides) {
List<Account> rows = new List<Account>();
for (Integer i = 0; i < count; i++) {
Account a = new Account(
Name = 'Test Account ' + uniq() + '-' + i
);
rows.add(a);
}
for (Account a : rows) applyOverrides(a, overrides);
insert rows;
return rows;
}
// ---------- Contact (lookup → Account) ----------------------------------
public static Contact makeContact(Id accountId) {
return makeContact(accountId, new Map<String, Object>());
}
public static Contact makeContact(Id accountId, Map<String, Object> overrides) {
if (accountId == null) accountId = makeAccount().Id;
Contact c = new Contact(
LastName = 'Test ' + uniq(),
AccountId = accountId
);
applyOverrides(c, overrides);
insert c;
return c;
}
// ---------- shared -------------------------------------------------------
public static Map<String, Object> overrides(String key, Object value) {
return new Map<String, Object>{ key => value };
}
private static Integer counter = 0;
private static String uniq() {
counter++;
return String.valueOf(System.currentTimeMillis()) + '-' + counter;
}
private static void applyOverrides(SObject record, Map<String, Object> overrides) {
if (overrides == null) return;
for (String field : overrides.keySet()) {
record.put(field, overrides.get(field));
}
}
}3. Generate the meta file
<?xml version="1.0" encoding="UTF-8"?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>{{platform.apiVersion}}</apiVersion>
<status>Active</status>
</ApexClass>4. Per-type defaults
| sObject field type | Default test value |
| string / textarea | 'Test ' + uniq() |
uniq() + '@example.com' | |
| phone | '555-555-' + uniq().right(4) |
| currency / number | 100 |
| percent | 50 |
| date | Date.today() |
| datetime | Datetime.now() |
| boolean | false |
| picklist (required) | first active value from describe |
| picklist (optional) | omitted |
| reference (required) | call the appropriate make<Parent>() factory and use .Id |
| reference (optional) | omitted |
| reference (User) | UserInfo.getUserId() |
| record-type ID | first active record type from describe |
5. Multi-object factories preserve order
When multiple objects are given, generate factories in dependency order (parent before child). E.g., Order_Item__c, Order__c, Account → emit makeAccount, makeOrder, makeOrderItem (Account → Order → OrderItem).
6. Output
Write ${APEX_SRC}/<ClassName>.cls and <ClassName>.cls-meta.xml. Print a summary:
[test-data] Wrote TestDataFactory.cls (3 sObjects: Account, Order__c, Order_Item__c)
[test-data] Required fields populated; lookups resolved through factories
[test-data] Update with: /argo:test-data --update ContactIf --update was passed and the factory already exists, append new methods (do not duplicate; idempotent insert).
7. Exit codes
- 0 — factory written
- 1 — sObject(s) not found in cache and
sfCLI not available - 2 — write error / config error
Rules
- Insert by default.
make<Object>()returns an inserted record so tests can use.Iddirectly. Override pattern:make<Object>(overrides)for fields,makeMemoryOnly<Object>()if you need a non-inserted record (rare; only generate that variant if the user asks) - Always use
with sharingsemantics implicitly — factory is@isTestannotated so it runs with test context - Don't use
Test.loadData. It depends on static resources and breaks when fields change - Don't hardcode IDs. Always derive lookup values from another factory call
- Don't pre-populate audit fields (
CreatedDate,LastModifiedDate); they'd be ignored anyway, and tests that need to fake them should useTest.setCreatedDate - Counter + timestamp uniqueness for any field that needs to be unique across rows (Email, ExternalId, Username)
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

