Skip to main content
Glama

generate_factory

Creates reusable test factories for BackGen resources, generating valid instances with sensible defaults and faker-based data to simplify test setup.

Instructions

Creates a test factory file for a resource — a reusable builder that generates valid resource instances with sensible defaults for writing tests. Factories let you create test data in one line (e.g. createProduct({ name: 'Widget' })) instead of manually constructing full objects with required fields, timestamps, and relations every time. The generated factory is ORM-aware: it uses the same schema as your generated resource. Factories are written to src/factories/.factory.ts and use the faker library for realistic default values. Run generate_resource for a resource first — the factory matches its fields. Only PascalCase resource names are valid (e.g. 'Product', not 'product').

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
resourceYesResource name in PascalCase — must start with an uppercase letter. Examples: 'Product', 'User', 'Appointment'. Must match an existing resource generated by generate_resource.
dirNoAbsolute or relative path to the BackGen-generated project directory. Defaults to the current working directory. Example: '/home/user/projects/my-api'.
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries full burden and does well, detailing output location, use of faker, ORM-awareness, and schema dependency. However, it doesn't mention whether the tool overwrites existing files or has other side effects.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is front-loaded with the main purpose, each sentence adds value, and there is no redundancy or irrelevant information.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no output schema and no annotations, the description is fairly complete, covering prerequisites, naming, output location, and usage. Minor gap: no mention of overwrite behavior, but overall sufficient.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, and the description adds value by reinforcing the PascalCase constraint and providing example usage. It provides context beyond the schema's field descriptions.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states it creates a test factory file for a resource, explains what a factory is with an example, and distinguishes from sibling tools like generate_resource by specifying it as a prerequisite.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description explicitly tells when to use the tool (after generate_resource) and provides a naming constraint (PascalCase only), offering clear guidance and preventing common mistakes.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/IbrahimKhaled19/BackGen'

If you have feedback or need assistance with the MCP directory API, please join our Discord server