---
title: Quickstart
description: Sign up from the terminal, define your first luna and call it over HTTP.
sidebar:
  order: 1
---

At the end of this page you have a luna running on Luna. It stores a list of items and returns them over HTTP. Every step runs in the terminal, in your project's folder.

## Start with your agent

Copy the prompt into your coding agent to have it follow this page for you.

**Set up Luna in this project with your coding agent.**

> Set up Luna in this project.
>
> 1. Install the Luna skill, then read it: `npx skills add gabrieldrl/luna-skills`
> 2. Run `luna whoami`. If this machine is not logged in, run `luna signup`. It opens a sign-up page in my browser. Wait for me to finish there.
> 3. If `luna whoami` shows no organisation, ask me for a name and run `luna orgs create <name>`.
> 4. In the project folder, run `luna projects create <name>`, then `luna env create dev`.
> 5. Install the SDK with `npm install --install-links "$(luna sdk ts --path)"`. Add `luna/luna.config.ts` and define one public luna in `luna/lunas/`.
> 6. Run `luna dev`. Call a handler with the URL and key it writes to `.env.local`, and show me the response.

The prompt has your agent install the Luna skill first. The skill teaches an agent how to define, deploy and call lunas. To install it yourself, run this in your project folder:

```bash
npx skills add gabrieldrl/luna-skills
```

## Prerequisites

- The `luna` CLI. Run `luna version` to check that it is installed.
- Node.js 22.18 or later.

1. **Sign up**

    ```bash
    luna signup
    ```

2. **Create an organisation**

    ```bash
    luna orgs create Acme
    ```

3. **Create a project and an environment**

    ```bash
    luna projects create notes
    ```

    ```bash
    luna env create dev
    ```

4. **Define a luna**

    Install the TypeScript SDK.

    ```bash
    npm install --install-links "$(luna sdk ts --path)"
    ```

    Add a `luna` folder with these two files.

    - luna/
      - luna.config.ts
      - lunas/
        - list.ts

    ```ts luna/luna.config.ts
    import { defineConfig } from "luna";

    export default defineConfig({ lunas: "./lunas/list.ts" });
    ```

    ```ts luna/lunas/list.ts
    import { defineLuna, t, table } from "luna";

    export const List = defineLuna({
      name: "List",
      visibility: "public",
      key: { id: t.string() },
      schema: {
        items: table({ id: t.id(), text: t.string() }),
      },
      handlers: (h) => ({
        add: h({ args: { text: t.string() } }, (ctx, { text }) => {
          ctx.db.items.insert({ text });
        }),
        all: h({ query: true }, (ctx) => ctx.db.items.find({ orderBy: "id" })),
      }),
    });
    ```

5. **Run it**

    ```bash
    luna dev
    ```

## Call your luna

`luna dev` writes the app's URL and publishable key to `.env.local`. In a second terminal, in the same folder, load them.

```bash
source .env.local
```

Add an item to the list named `groceries`.

```bash
curl -X POST "$LUNA_URL/List/groceries/add" \
  -H "luna-key: $LUNA_KEY" \
  -H "Content-Type: application/json" \
  -d '{"text":"milk"}'
```

Read the list back.

```bash
curl -X POST "$LUNA_URL/List/groceries/all" -H "luna-key: $LUNA_KEY"
```

```json
[{"id":1,"text":"milk"}]
```

## Next steps

- Change a handler in `luna/lunas/list.ts` and save. `luna dev` deploys the change.
- Run `luna status` to see the environment's URL, its luna types and its calls.
- Run `luna deploy --env production` when the app is ready for production.
