Running a Hello World

Get started with Forge&Hive by creating and running your first task

Published: 4/18/2025

In Forge&Hive projects, the typical development workflow involves creating and testing tasks via the CLI before integrating them into your application. This approach accelerates development by eliminating the need to switch between tools like browsers or Postman.

This tutorial will guide you through setting up a hello world project and running your first Forge&Hive task.

Installing the Forge&Hive CLI

First, install the Forge&Hive CLI globally:

pnpm i -g @forgehive/forge-cli

Note: You can also use npm (npm install -g @forgehive/forge-cli) or yarn (yarn global add @forgehive/forge-cli).

Verify your installation:

forge info

Creating a New Project

1.- Create a project directory and initialize your package:

mkdir hello-world-project
cd hello-world-project
pnpm init

2.- Install the required Forge&Hive packages:

pnpm add @forgehive/task @forgehive/schema

3.- Create the necessary directories:

mkdir src
mkdir logs

4.- Initialize your Forge&Hive project:

forge init

This command creates a forge.json file, completing your project setup.

Creating and Running Your First Task

Create a task using the Forge&Hive CLI:

forge task:create samples:helloWorld

This generates a new file at src/tasks/samples/helloWorld.ts. Run the task with:

forge task:run samples:helloWorld

You should see output similar to:

========================================
Running: task:run samples:helloWorld {}
========================================
input: {}
boundaries: {}
===============================================
Outcome { outcome: 'Success', taskName: 'task:run', result: { status: 'Ok' } }
===============================================

Congratulations! You've successfully created and run your first Forge&Hive task.

Next Steps

Now that you've got the basics, continue your journey by learning how to Build Real-World Tasks.