Guided Tutorials
Generate a Full CRUD Feature
Add a complete create, read, update, delete feature to an existing project with validation and tests.
What you'll learn
- How to describe a feature with enough detail for the agent to generate accurate code
- How Autohand reads existing patterns and matches them in generated files
- How to verify generated tests pass and extend the feature with follow-up prompts
Before you start
- Autohand Code installed
- An existing project with at least one resource already implemented
- A test setup already in place (Vitest, Jest, or Mocha)
- Zod or another validation library installed
Describe the feature
Be specific about the data shape, relationships, and business rules when writing your prompt. The agent uses these details to generate accurate validation schemas and correct database queries.
Describe:
- Fields and their types. For blog posts:
title(string, required),body(text, required),published(boolean, default false),authorId(foreign key to users). - Relationships. A post belongs to a user. A user can have many posts.
- Validation rules. Title must be between 5 and 200 characters. Body must not be empty.
authorIdmust reference an existing user. - Any special behavior. Only published posts should appear in the public list endpoint. The author can see all their own posts.
Run the prompt
Navigate to your project root and run the prompt. The agent reads the existing codebase before generating anything.
You will see the agent read several files first. It is looking at your existing models, routes, and tests to understand the patterns already in use.
The agent generates the new feature using the same patterns it found in your existing code. You get output that looks like it was written by the same developer who wrote the rest of your project.
Generated files
A typical CRUD feature for blog posts produces these files.
The route file is also registered in your main app file. The agent finds where you import and mount other routers and adds the new one in the same place.
The Zod schema covers both create and update cases. The update schema uses .partial() so all fields are optional on PATCH requests.
Verify the tests pass
Run your test suite immediately after generation. The agent should produce passing tests.
If any test fails, read the error message and ask Autohand to fix it.
Customize the output
Once the tests pass, extend the feature with follow-up prompts. The agent keeps all changes consistent with the code it just generated.
Tip: Run the test suite after each follow-up. Catching a regression early is much easier than debugging three changes at once.
What you learned
- You described a feature with fields, relationships, and validation rules so the agent generated accurate code
- You watched Autohand read existing patterns and produce files that match your project style
- You verified the generated tests pass and extended the feature with soft delete, search, and pagination