# Grok and Claude bots: picking up your answers

When you approve an ask on your board, the answer reaches your hub within about a minute. Whether a bot then acts on it by
itself depends on what the bot runs in:

- **A chat app in a browser.** Grok's app, ChatGPT, Claude.ai and the like only act when someone types. Your answer waits on the board until you next message the bot, or ask it to check.
- **An agent: Grok Build or Claude Code.** Give it the loop prompt below. It checks every 5 minutes for as long as its session is open on the hub's machine, and Grok Build's loops stop after 7 days, so start it again each week.
- **A script.** Run its check from cron (or the machine's scheduler) every 5 minutes. It keeps going with nobody there.

Replace YOUR_ID with the bot's id on the board, HUB_FOLDER with the folder that has barncleuth_status.py, and set
HUB_CONTROL_DIR to the hub's control folder. The same prompts, with Copy buttons, are at
https://barncleuth.com/docs/picking-up-answers.

## Grok Build

Paste this into Grok Build, in the hub's folder. Stop it from the tasks pane (Ctrl+G), or ask Grok to cancel it.

```text
/loop 5m You're my bot YOUR_ID on Barncleuth Workstation. Each run, pick up my answers to your asks and act on them. The hub kit (barncleuth_status.py) is in HUB_FOLDER, and my answers arrive in the hub's control folder: run every command with HUB_CONTROL_DIR set to it. You never need a key, and you never open the board.

1. List the asks I've answered that you haven't finished:
   for f in "$HUB_CONTROL_DIR"/decisions/*; do if [ -f "$f" ] && [ "$(head -n 1 "$f")" = YOUR_ID ]; then sed -n 3p "$f"; fi; done
   Nothing listed: stop here. Don't report, don't message me, say nothing.
2. For each ask id it lists, read my answer:
   python3 HUB_FOLDER/barncleuth_status.py --decision ASK_ID
   approve: do that step, once, exactly as the ask said. reject: don't do it. pending: leave it for a later run. done: you've already finished it; skip it.
   If you said Working on one in an earlier run and it's still going, leave it to that run.
3. Before you start, say so (the board shows Seen, then Working):
   python3 HUB_FOLDER/barncleuth_status.py --ack ASK_ID --note "On it"
   python3 HUB_FOLDER/barncleuth_status.py --working ASK_ID
4. When it's finished, say what happened, with a link to the result if there is one:
   python3 HUB_FOLDER/barncleuth_status.py --done ASK_ID --link "https://..." --note "What you did, in a few words"
   If it didn't work:
   python3 HUB_FOLDER/barncleuth_status.py --failed ASK_ID --reason "What went wrong, in words I can act on"
   After a reject: --done ASK_ID --note "Not done, as you said".
5. Only what I approved. Anything else that needs a yes is a new ask. An answer you can't read is a no. Never say something happened that you didn't see happen.
```

## Claude Code

Paste this into a Claude Code session on the hub's machine and leave the session open. To stop it, end the session or ask Claude to stop the loop.

```text
/loop 5m You're my bot YOUR_ID on Barncleuth Workstation. Each run, pick up my answers to your asks and act on them. The hub kit (barncleuth_status.py) is in HUB_FOLDER, and my answers arrive in the hub's control folder: run every command with HUB_CONTROL_DIR set to it. You never need a key, and you never open the board.

1. List the asks I've answered that you haven't finished:
   for f in "$HUB_CONTROL_DIR"/decisions/*; do if [ -f "$f" ] && [ "$(head -n 1 "$f")" = YOUR_ID ]; then sed -n 3p "$f"; fi; done
   Nothing listed: stop here. Don't report, don't message me, say nothing.
2. For each ask id it lists, read my answer:
   python3 HUB_FOLDER/barncleuth_status.py --decision ASK_ID
   approve: do that step, once, exactly as the ask said. reject: don't do it. pending: leave it for a later run. done: you've already finished it; skip it.
   If you said Working on one in an earlier run and it's still going, leave it to that run.
3. Before you start, say so (the board shows Seen, then Working):
   python3 HUB_FOLDER/barncleuth_status.py --ack ASK_ID --note "On it"
   python3 HUB_FOLDER/barncleuth_status.py --working ASK_ID
4. When it's finished, say what happened, with a link to the result if there is one:
   python3 HUB_FOLDER/barncleuth_status.py --done ASK_ID --link "https://..." --note "What you did, in a few words"
   If it didn't work:
   python3 HUB_FOLDER/barncleuth_status.py --failed ASK_ID --reason "What went wrong, in words I can act on"
   After a reject: --done ASK_ID --note "Not done, as you said".
5. Only what I approved. Anything else that needs a yes is a new ask. An answer you can't read is a no. Never say something happened that you didn't see happen.
```

## A script, from cron

```text
*/5 * * * * cd HUB_FOLDER && HUB_CONTROL_DIR=/path/to/control ./your-bot.sh check-answers >> your-bot.log 2>&1
```

The script's check-answers step does the same five steps in code. Finding the answers waiting for it, in Python:

```text
import os, subprocess

CONTROL = os.environ["HUB_CONTROL_DIR"]
ME = "YOUR_ID"

def waiting_answers():
    folder = os.path.join(CONTROL, "decisions")
    for name in sorted(os.listdir(folder)) if os.path.isdir(folder) else []:
        path = os.path.join(folder, name)
        if os.path.isfile(path):
            lines = open(path, encoding="utf-8").read().splitlines()
            if len(lines) >= 3 and lines[0] == ME:
                yield lines[2], lines[1]   # the ask id, and approve or reject

def helper(*args):
    subprocess.run(["python3", "barncleuth_status.py", *args], check=True)
```

Nothing here approves anything. A bot still acts only on an "approve" for that exact ask, and an answer it can't read is a no.
