Factories

Automatically spawn and terminate claws based on Linear or Shortcut issue status changes.

Factories are in beta. Linear and Shortcut are supported. GitHub Issues and cron triggers are planned.

How factories work

A factory watches an external system for events. When a trigger condition is met (e.g. an issue enters a status), it spawns a new claw pre-loaded with context from that event. When the claw sends [DONE] <pr-url>, the factory moves the issue to the done status and keeps the claw alive to watch for CI failures and review comments. The claw terminates automatically when the PR is merged or closed.

If terminate_on_leave: true is set, dragging the issue back out of the trigger status will immediately kill the claw and its VM.

Linear factory setup

1. Get the webhook URL

Find it in Settings → Factories in the hub web UI, or construct it:

bash
https://your-hub.example.com/api/integrations/linear/webhook

2. Create a Linear webhook

  1. Go to Linear → Settings → API → Webhooks
  2. Click New webhook, paste the URL above
  3. Check Issues under Data change events
  4. Copy the Signing secret

3. Get a Linear API key

Go to Linear → Settings → API → Personal API Keys and create a key.

4. Configure hub.yaml

yaml
integrations:
  linear:
    - workspace: my-company
      api_key: lin_api_...
      # webhook_secret is per-factory (set in Settings → Factories)

factories:
  - name: feature-factory
    integration: linear
    workspace: my-company
    team: ELA                        # optional — filter by team key
    trigger_status: "Ready for Agent"
    done_status: "In Review"
    terminate_on_leave: true
    template: base
    webhook_secret: whsec_...        # signing secret from step 2
    tags:                            # optional — applied to created claws
      - linear
    color: teal

Shortcut factory setup

See the Shortcut Integration guide for full setup instructions.

yaml
integrations:
  shortcut:
    - workspace: my-company
      token: YOUR_SHORTCUT_TOKEN

factories:
  - name: sc-factory
    integration: shortcut
    workspace: my-company
    trigger_status: "In Development"
    done_status: "In Review"
    terminate_on_leave: true
    template: base

The [DONE] signal

When an agent finishes its task, it sends [DONE] followed by the PR URL as a chat message:

text
[DONE] https://github.com/org/repo/pull/42

The hub then:

  1. Validates the PR is open
  2. Moves the issue/story to done_status
  3. Keeps the claw alive to watch for CI failures and bugbot comments
  4. Terminates the claw when the PR is merged or closed

Add this to your agent's AGENTS.md:

markdown
When your task is complete, open a PR and send:
[DONE] https://github.com/org/repo/pull/N

This moves the issue and keeps you alive to watch CI and review comments.
You'll terminate automatically when the PR merges.

Auto-watching CI and bugbot

While a claw is in the watching state (after [DONE]), the hub polls the PR every 2 minutes for:

  • CI failures — failed check runs inject a message telling the agent to fix them
  • Bugbot comments — new Cursor bugbot comments are injected as user messages
  • PR merged/closed — terminates the claw and destroys the VM

You can disable per-template with:

yaml
# in elasticclaw-config.yaml
auto_watch_ci: false
auto_watch_bugbot: false

Or toggle per-claw from the dashboard card back.

Activity log

Every webhook event is logged for 4 hours. Click Activity next to any factory in Settings to see:

  • claw_created — issue entered trigger status, claw spawned
  • claw_terminated — issue left trigger status, claw killed
  • error — provisioning failed
  • not_actionable — webhook received but status didn't match

1:1 enforcement

Each issue/story can only have one active claw at a time. If the same issue is moved into the trigger status again while a claw already exists, a new one will not be created.