Générer des données de test Frappe avec Faker

VérifiéPrudence

Génère des enregistrements de test réalistes et liés pour Frappe/ERPNext via la CLI bench faker, puis les supprime.

Spar Skills Guide Bot
TestingIntermédiaire
21/09/2026
Claude CodeCursorCodex
#frappe#erpnext#test-data#cli#seeding

Recommandé pour

Synthèse automatique

Génère des enregistrements de test Frappe/ERPNext réalistes et correctement liés via la CLI `bench faker`, dans un lot identifié qui pourra être annulé ensuite.

Points forts

  • Résout et insère tout le graphe de dépendances du DocType dans un ordre compatible avec les clés étrangères, en réutilisant les enregistrements déjà présents au lieu de les dupliquer.
  • `faker plan` affiche l'arborescence des dépendances, avec les DocTypes déjà remplis, avant toute écriture en base.
  • L'option `--instructions` accepte des contraintes en langage naturel (villes, salaires, rôles, relations) que le LLM applique aux enregistrements.
  • Chaque exécution renvoie un identifiant de lot, et `cleanup --batch` supprime les enregistrements dans l'ordre inverse des dépendances, y compris après un plantage partiel.

Limites

  • Nécessite l'app Frappe Faker installée sur le site et un fournisseur d'IA configuré dans Faker Settings ; sans cela aucune génération n'est possible.
  • La qualité des données dépend du LLM : des échecs par enregistrement peuvent survenir et obliger à réduire le nombre demandé ou à simplifier les instructions.
  • L'annulation repose uniquement sur l'identifiant de lot affiché à la génération ; il faut donc le conserver pour pouvoir nettoyer la base.
Quand l'utiliser

À utiliser lorsqu'un test, une démo ou une reproduction locale a besoin de données de départ pour un DocType Frappe/ERPNext absent du site.

Quand l'éviter

À éviter sur un site de production ou lorsqu'il faut des jeux de données déterministes, strictement identiques d'une exécution à l'autre.

Analyse de sécurité

Prudence
Score qualité88/100

The skill uses the bench CLI to generate and clean up test data in a Frappe/ERPNext site. While the actions are legitimate and scoped to a batch rollback, they still modify database state and should be used only on test/demo environments, not production.

Points d'attention
  • •Commands insert and delete database records via the bench CLI, which could affect a live site if misused.
  • •The skill assumes the agent has access to run bench commands, which are not declared as allowed tools.
Comment cette analyse est faite

Exemples

Seed and roll back Sales Orders
I need some Sales Orders on demo.localhost to test an API — inspect the dependency plan, generate 5 with realistic Indian customers, then clean up the batch when I'm done.
Employees in Chennai
Create test Employees in Chennai so I can test our payroll endpoint: first run bench --site demo.localhost faker plan --doctype "Employee", then generate 10 with plausible engineering roles and salaries.
Plan before generating
Run bench --site staging.localhost faker plan --doctype "Salary Slip" and tell me which dependencies already have data and which ones faker will create before I generate anything.

name: faker-data description: Generate realistic, correctly-linked Frappe/ERPNext test records for any DocType using the bench faker CLI, then roll them back when done. Use when a test, demo, or local repro needs seed data and the site is missing it — e.g. "I need some Sales Orders", "seed data so I can test this API", "create test Employees in Chennai", or "populate the database to test this endpoint".

Frappe Faker — Generate Test Data from the CLI

Use this skill when you need realistic, linked Frappe/ERPNext test records for a specific DocType. Faker resolves the full dependency graph, generates all linked records via LLM, and inserts them in FK-safe order. Every run produces a Faker Batch ID that you can use to delete all generated records when testing is done.

Prerequisites

  • The Frappe Faker app must be installed on the site
  • Faker Settings must have a configured AI provider (check /app/faker-settings)
  • The RQ background worker is not needed — CLI runs synchronously in the terminal

Workflow

1. Inspect dependencies first

bench --site <site> faker plan --doctype "<DocType>"

This shows the full dependency tree without generating anything. Look for:

  • [Has data — will skip] — existing records will be reused; no generation needed
  • [Cyclic] — cycle detected; generation will still proceed
  • [Target] — the DocType you requested

Example output:

Dependency plan for: Salary Slip

Salary Slip  [Target]
  Salary Structure Assignment
    Employee
      Department  [Has data — will skip]
    Company  [Has data — will skip]
  Salary Structure

2. Generate records

bench --site <site> faker generate \
  --doctype "<DocType>" \
  --count <N> \
  --instructions "<free-text requirements>"

Options:

  • --count / -n — number of target doctype records (dependencies get min(count, 5))
  • --skip — comma-separated list of DocTypes to skip (e.g. --skip "Employee,Company")
  • --instructions — natural language constraints passed to the LLM
  • --no-fast-insert — use standard doc.insert() path (runs Python hooks; slower)

Example:

bench --site demo.localhost faker generate \
  --doctype "Salary Slip" --count 3 \
  --instructions "Employees are software engineers in Bangalore, monthly salary 80k-120k INR, use existing company"

Output:

Generating 3 record(s) for Salary Slip...

Batch: abc123def456  |  Created: 12  |  Failed: 0
  Department: 0 created  (skipped — has data)
  Employee: 3 created
  Salary Structure: 3 created
  Salary Structure Assignment: 3 created
  Salary Slip: 3 created

3. Run your tests

Use the generated records for whatever testing or API calls you need.

4. Clean up

bench --site <site> faker cleanup --batch <batch_id>

This deletes all records from the batch in reverse dependency order (FK-safe). Use the batch ID printed by faker generate.

bench --site demo.localhost faker cleanup --batch abc123def456
# → Deleted 12 record(s). Status: Rolled Back

Tips

  • Use --instructions liberally — the LLM respects free-text constraints like dates, locations, salary ranges, roles, and relationships between records
  • Skip doctypes with existing data — if your site already has Employees, use --skip "Employee" to reuse them and avoid duplication
  • Check for errors — if Failed > 0, re-run with a lower count or simpler instructions; per-record errors are logged in the output
  • Batch rollback is partial-crash-safe — if generation crashes mid-way, the batch still tracks all successfully inserted records; cleanup will roll back only what was tracked

Rollback from the UI

Open the Frappe Faker web app at /faker, go to History, click a run row, and use the Rollback button in the detail dialog to delete that batch's records without touching the terminal.

Du fichier au premier essai

Le téléchargement contient exactement le contenu affiché sur cette fiche. Cette copie peut différer de la dernière version du dépôt source.

Consulter la source et ses fichiers annexes

Ce téléchargement contient uniquement SKILL.md. Les scripts, références, modèles et dépendances éventuels ne sont pas inclus. Récupérez les fichiers nécessaires depuis la source en conservant leur arborescence avant de poursuivre.

1. Télécharger le fichier

Télécharger SKILL.md

Depuis la racine d’un projet de test, enregistrez le fichier sous .skill-downloads/generate-frappe-test-data-with-faker-muar2z0h/SKILL.md, ou utilisez la commande suivante. Ce dossier sert à examiner la skill avant son installation.

Commande pour macOS/Linux ou WSL : un shell POSIX et curl sont nécessaires. Sous Windows sans WSL, utilisez le bouton de téléchargement et créez le dossier manuellement.

mkdir -p '.skill-downloads/generate-frappe-test-data-with-faker-muar2z0h' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/generate-frappe-test-data-with-faker-muar2z0h/download' --output '.skill-downloads/generate-frappe-test-data-with-faker-muar2z0h/SKILL.md.part' && mv '.skill-downloads/generate-frappe-test-data-with-faker-muar2z0h/SKILL.md.part' '.skill-downloads/generate-frappe-test-data-with-faker-muar2z0h/SKILL.md'

2. Vérifier les prérequis

Lisez SKILL.md avant de l’utiliser. Si le fichier cite des scripts ou services externes, examinez-les et préparez les accès nécessaires dans votre environnement de test.

Extrait original : Prerequisites
  • The Frappe Faker app must be installed on the site
  • Faker Settings must have a configured AI provider (check /app/faker-settings)
  • The RQ background worker is not needed — CLI runs synchronously in the terminal

Les plateformes de la fiche sont des indications du catalogue. Les chemins ci-dessous suivent la documentation des outils ; ils ne prouvent pas que cette skill y a été exécutée. Aucune version minimale de ces outils n’est attestée pour cette fiche.

3. Charger la skill

Après vérification, copiez le dossier complet dans le projet avec l’une des commandes ci-dessous, puis ouvrez une nouvelle session de l’outil. La commande s’arrête si un dossier du même nom existe déjà : comparez les fichiers avant de le remplacer.

Claude Code
test -f '.skill-downloads/generate-frappe-test-data-with-faker-muar2z0h/SKILL.md' && test -s '.skill-downloads/generate-frappe-test-data-with-faker-muar2z0h/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/faker-data' && cp -R '.skill-downloads/generate-frappe-test-data-with-faker-muar2z0h' '.claude/skills/faker-data'

Cursor
test -f '.skill-downloads/generate-frappe-test-data-with-faker-muar2z0h/SKILL.md' && test -s '.skill-downloads/generate-frappe-test-data-with-faker-muar2z0h/SKILL.md' && mkdir -p '.cursor/skills' && test ! -e '.cursor/skills/faker-data' && cp -R '.skill-downloads/generate-frappe-test-data-with-faker-muar2z0h' '.cursor/skills/faker-data'

Codex
test -f '.skill-downloads/generate-frappe-test-data-with-faker-muar2z0h/SKILL.md' && test -s '.skill-downloads/generate-frappe-test-data-with-faker-muar2z0h/SKILL.md' && mkdir -p '.agents/skills' && test ! -e '.agents/skills/faker-data' && cp -R '.skill-downloads/generate-frappe-test-data-with-faker-muar2z0h' '.agents/skills/faker-data'

OpenSkills

OpenSkills doit déjà être installé. La procédure locale install/read est contrôlée avec OpenSkills 1.5.0, qui exige Node.js ≥ 20.6.0. Aucun slug du catalogue n’est résolu automatiquement.

Installation officielle d’OpenSkills
openskills install './.skill-downloads/generate-frappe-test-data-with-faker-muar2z0h'

openskills read 'generate-frappe-test-data-with-faker-muar2z0h'

La lecture doit afficher le contenu du fichier installé et son dossier de base. Elle ne lance ni la skill ni ses dépendances.

Pour un agent qui lit AGENTS.md, synchronisez ensuite l’index. Cette commande modifie AGENTS.md : relisez le diff avant de l’utiliser.

openskills sync

Mode manuel ou autre outil : joignez SKILL.md à une conversation, ou ouvrez-le dans un agent capable de lire les fichiers. Ajoutez les ressources annexes nécessaires. Il n’existe pas de dossier universel reconnu par tous les outils.

4. Faire un premier essai

Utilisez une entrée courte et fictive : un endpoint d’API, un petit document ou un brief d’interface. Dans une nouvelle conversation, joignez le fichier ou donnez son chemin à l’agent, puis adaptez cette demande :

Lis .skill-downloads/generate-frappe-test-data-with-faker-muar2z0h/SKILL.md et applique ses instructions à cet exemple : [décrire une entrée de test]. Indique les fichiers, dépendances ou accès qui manquent. Produis le résultat demandé par la skill sans inventer de données ni exécuter de script non examiné.

Résultat attendu : une sortie correspondant aux instructions de la skill, ou une liste précise des prérequis manquants. Une simple confirmation de lecture ne valide pas le premier usage. Si une ressource externe est indisponible, ce parcours reste à tester.

Skills similaires