autohand "Create a REST API for a task management app with users, projects, and tasks. Use Express.js with PostgreSQL and include authentication middleware."

What you'll learn

  • How to write a specific scaffold prompt that produces a production-ready file structure
  • How Autohand generates routes, controllers, models, and middleware in one session
  • How to review, customize, and test the generated API
  • How to iterate on a working scaffold with follow-up prompts

Before you start

  • Autohand Code installed
  • Node.js 18 or newer
  • PostgreSQL running locally with a reachable database
  • An empty project directory with npm init -y already run

Define your requirements

The quality of what Autohand generates depends on how clearly you describe what you need. Before running the prompt, think through these questions.

  • What resources does the API manage? In this example: users, projects, and tasks. Be specific about the relationships. Tasks belong to projects. Projects belong to users.
  • What framework and database? Express.js and PostgreSQL here. If you prefer Fastify or MySQL, say so.
  • What authentication mechanism? JWT middleware in this case. You could also ask for session-based auth or API keys.
  • Any naming conventions or folder structure preferences? If your team uses a specific pattern, include it in the prompt.

A more specific prompt gets a more useful result. Compare these two:

Run the scaffold prompt

Navigate to your empty project directory and run Autohand with the prompt.

You will see the agent start working immediately. Watch the output as it plans the structure, then creates files one by one. A typical run looks like this:

The whole process takes about 60 to 90 seconds depending on the complexity of the request.

What Autohand creates

Here is what the generated project looks like.

Each layer has a clear job. Routes define the URL patterns and call controllers. Controllers handle HTTP concerns and call models. Models talk directly to PostgreSQL using parameterized queries. The auth middleware attaches the decoded JWT payload to req.user before protected routes run.

The generated .env.example lists every environment variable the app needs. Copy it to .env and fill in your values before starting the server.

Review and customize

Read through the generated files before running the server. Check these things in particular.

  • Database queries. Open src/models/User.js and scan the SQL. Confirm the table and column names match your actual schema, or adjust the migration file the agent created.
  • JWT secret handling. The auth middleware reads process.env.JWT_SECRET. Make sure this is set before production deployment.
  • Error responses. Check src/middleware/errorHandler.js. The default format returns { error: message }. Change it to match your team's conventions if needed.
  • Validation. The scaffold includes basic input checking, but you may want to add stricter validation with a library like Zod or Joi.

If you want to adjust something, just ask Autohand directly:

Test the API

Start the server and hit a few endpoints with curl to confirm everything is working.

Register a new user:

Log in to get a token:

Create a project using the token:

Iterate

Once the base API is working, add features by continuing the session. Keep the same Autohand session open or start a new one in the same directory. The agent will read the existing code before making changes.

Each follow-up prompt reads the existing code first, so the agent keeps its changes consistent with what is already there.

Tip: Commit the working scaffold to git before iterating. That way you have a clean baseline to diff against and can revert if a follow-up takes things in the wrong direction.

What you learned

  • You scaffolded a complete REST API with routes, controllers, models, and auth middleware from a single prompt
  • You reviewed the generated file structure and verified the server responds correctly
  • You tested endpoints with curl and confirmed JWT authentication works
  • You extended the API with follow-up prompts for rate limiting, pagination, and migrations
Try next autohand "Add a complete CRUD feature for blog posts to this project. Include model, routes, validation with Zod, and unit tests."