# Tricks **Page:** guides/tricks [Download Raw Markdown](./guides/tricks.md) --- # Tricks Each trick on this page is a few lines you can paste into a terminal or into `~/.bashrc` (or `~/.zshrc`). The snippets use the [Hoody CLI](/foundation/cli/), plain `curl` and `ssh`. Keys and tokens come from environment variables, never from the command line. ## Hoody Bots from your shell These read two variables. Put the URL in your shell profile, and load the key once per session with `read -rs`, so it never lands in your history: ```bash # ~/.bashrc export HOODY_BOT='https://amber-falcon-river-k7m2q.hoody.bot' ``` ```bash # In the shell, once per session (not in ~/.bashrc): paste the hbk_ key; it is not shown read -rs HOODY_BOT_KEY && export HOODY_BOT_KEY ``` The Hoody CLI reads `HOODY_BOT_KEY` on its own; there is no `--key` flag. Everyone who holds a key to the same Bot shares one conversation with it. See [Bot URLs](/kit/agent/bot-urls/) for creating the URL and its keys. ### Ask your Bot in one word ```bash ask() { hoody boturls ask "$HOODY_BOT" -- "$*"; } ask what is blocking the release ``` `ask` sends the message and waits for the reply, for up to 10 minutes. `--` keeps a message that starts with `-` from being read as a flag. ### Pipe a diff or a log into the Bot ```bash askp() { local input; input=$(cat) || return; hoody boturls ask "$HOODY_BOT" -- "$*"$'\n\n'"$input"; } git diff --cached | askp "Review this staged diff" tail -n 200 build.log | askp "Why did this build fail?" ``` The question comes first, then whatever arrives on standard input. A message holds up to 64 KiB of text. ### Stream the reply as it is written ```bash chat() { hoody boturls chat "$HOODY_BOT" -- "$*"; } ``` `chat draft a release note for v2.3` prints the reply piece by piece instead of all at once. ### Pick up a long answer later ```bash hoody boturls ask "$HOODY_BOT" --no-wait -o json -- "Audit the test suite" | jq '{status, ref}' # Later: wait for that same reply; nothing new is sent hoody boturls ask "$HOODY_BOT" --ref '' --max-wait 1800 ``` When `status` is `working`, the `ref` lets you come back for the answer without posting the task twice. ### One function per Bot ```bash workbot() { hoody boturls ask "$WORK_BOT" --key-env WORK_BOT_KEY -- "$*"; } ``` `--key-env` names the variable that holds this Bot's key, so several Bots never share `HOODY_BOT_KEY`. ### Approve an agent's question from any terminal ```bash hoody boturls status "$HOODY_BOT" hoody boturls answer "$HOODY_BOT" --gate-id '' --decision approve ``` `status` lists the approvals the Bot's agents are waiting on. `--decision` takes `approve`, `allow_session`, `deny` or `answer` (with `--text`). ### Use your Bot as Claude Code's model ```bash alias claude-bot='ANTHROPIC_BASE_URL="$HOODY_BOT" ANTHROPIC_API_KEY="$HOODY_BOT_KEY" ANTHROPIC_MODEL=claude-sonnet-4-5 CLAUDE_CODE_ENABLE_PROMPT_SUGGESTION=false claude' ``` On the first start, answer Yes to using the detected API key. The Bot answers in text and does not run Claude Code's tools. Codex, opencode and pi work too; see [Use it from a coding agent](/kit/agent/bot-urls/calling/#use-it-from-a-coding-agent). ## Computer URLs ### Build a service URL ```bash # ~/.bashrc: replace the three values with your computer's export PROJECT_ID='replace-with-project-id' COMPUTER_ID='replace-with-computer-id' SERVER='replace-with-server' hurl() { printf 'https://%s-%s-%s-%s.%s.computers.hoody.com\n' \ "$PROJECT_ID" "$COMPUTER_ID" "${1:?service}" "${2:-1}" "$SERVER" } hurl files # files-1 hurl terminal 2 # terminal-2 hurl http 3000 # whatever listens on port 3000 ``` `hurl` always adds an instance number. SSH is the exception: its host is `{projectId}-{computerId}-ssh.{server}.computers.hoody.com`, with no instance suffix. The tricks below use `hurl`. Each service and its URL are listed in [Hoody Kit](/kit/). ### Every port is already a URL ```bash curl "$(hurl http 3000)/" ``` A dev server listening on port 3000 inside the computer is reachable over HTTPS, within the computer's [proxy permissions](/foundation/proxy/permissions/). For a short name, create an alias: `hoody proxy aliases create --computer-id "$COMPUTER_ID" --alias my-app --program http --port 3000`. In the Hub, open **Computers**, select the computer, then open **Ports & addresses**. Under **Aliases**, choose **Create alias**, enter `3000` under **Port** and `my-app` under **Alias**, then choose **Create alias**. See [Proxy aliases](/foundation/proxy/aliases/). ### Download a folder as a ZIP ```bash curl -fS "$(hurl files)/documents/?zip" -o documents.zip curl -fsS "$(hurl files)/backup.tar.gz?preview" # list an archive without downloading it ``` In the Hub, open **Files**, pick the computer, and choose **Download as .zip** from the folder's menu. For a folder on the computer's filesystem, a ZIP that would hold more than 1,000,000 visible files, scan more than 10,000,000 entries, or go deeper than 50 levels is refused with 422 `ARCHIVE_TOO_LARGE`; download its subfolders separately. See [Hoody Files](/kit/files/). ### Upload a script that is already executable ```bash curl -fsS -X PUT "$(hurl files)/api/v1/files/scripts/report.sh?chmod=755" --data-binary @report.sh ``` The file is written and its mode set in one request. ### Send a file between two machines ```bash # Machine A curl -T report.pdf "$(hurl pipe)/api/v1/pipe/report" # Machine B: either side can start first curl "$(hurl pipe)/api/v1/pipe/report" > report.pdf ``` Pipe does not save transferred files. Hoody Proxy logs may retain request and response body content; see [Auditing](/concepts/auditing/#what-do-proxy-logs-record). Each side waits for the other for up to 300 seconds by default. See [Pipe](/kit/pipe/). ### Reach a database on another machine ```bash # On the machine with the database hoody pipe forward pg --ws --connect 127.0.0.1:5432 -c "$COMPUTER_ID" # On your machine hoody pipe forward pg --ws --listen 127.0.0.1:15432 -c "$COMPUTER_ID" # In another terminal, while --listen runs psql -h 127.0.0.1 -p 15432 ``` `--listen` opens a local port on your machine and `--connect` dials the database. It carries one TCP connection at a time, so run `--connect` again for the next client. Any TCP service works the same way. ### Turn a POST into a link ```bash curl -fsSG "$(hurl curl)/api/v1/curl/request" \ --data-urlencode "url=$TARGET_URL" \ --data-urlencode 'method=POST' \ --data-urlencode 'json={"action":"check"}' \ --data-urlencode 'response=transparent' ``` Hoody cURL makes the POST for you, so a tool that can only open a URL can still trigger it. `--data-urlencode` keeps spaces, `&` and nested JSON intact. See [Hoody cURL](/kit/curl/). ### Get a notification when a job finishes ```bash done-notify() { jq -n --arg body "$1 finished" '{display: "1", summary: "Done", body: $body}' | curl -fsS -X POST "$(hurl n)/api/v1/notifications/notify" \ -H "Content-Type: application/json" --data-binary @- > /dev/null || echo "done-notify: notification not sent" >&2 } make release; done-notify "make release" ``` The notification shows on display 1 of the computer. `-f` makes `curl` fail on an HTTP error, such as a 429 or 503, so a missed notification prints a message instead of passing silently. `notify` allows 10 requests a minute. See [Notifications](/kit/notifications/). ### Hand your account to any AI Paste `@https://hoody.com Connect to Hoody` into ChatGPT, Claude, Gemini or any AI that can run code with network access. It reads the Hoody Skill and sends you a browser sign-in link; once you approve, it can run your whole account. To hand it a token instead, give it a [scoped auth token](/foundation/hoody-api/authentication/), not your login. ## Hoody CLI ### Pick a computer with fzf ```bash hc() { COMPUTER_ID=$(hoody computers list --limit 100 -o json | jq -r '.computers[] | [.id, .name, .status] | @tsv' | fzf | cut -f1) export COMPUTER_ID HOODY_COMPUTER=$COMPUTER_ID } ``` After `hc`, every kit command targets the computer you picked, with no `-c`. To keep one computer across shells, save it instead: `hoody config set computer `. ### Snapshot before anything risky ```bash safe() { hoody snapshots create -c "$COMPUTER_ID" --alias "before-$(date +%Y%m%d-%H%M%S)" && hoody terminal commands run -c "$COMPUTER_ID" --ephemeral --command "$*" } safe "python3 migrate.py --destructive" ``` If it goes wrong, `hoody snapshots list -c "$COMPUTER_ID"` shows the snapshot to pass to `hoody snapshots restore -c "$COMPUTER_ID" -y`. In the Hub, open **Computers**, select the computer and open **Backups**. Choose **Take snapshot**, enter a **Name** and choose **Take snapshot**. To restore it, choose **Restore** on its row, then **Restore computer**. By default the CLI waits 30 seconds for the command's answer. No flag, environment variable or `config set` key changes that. A command that runs longer is reported as failed while it keeps running on the computer, up to its own `--timeout` (600 seconds by default with `--ephemeral`). Check that it has stopped before you restore the snapshot. ### One alias per account ```bash alias hw='hoody --profile work' alias hp='hoody --profile personal' ``` Each profile keeps its own sign-in, default computer and output format. Sign in once with `hw login`. ### Make scripts fail instead of prompting ```bash hoody --non-interactive -o json computers list | jq -r '.computers[] | .name' ``` `--non-interactive` turns interactive prompts into errors, but a destructive command may still read a confirmation from standard input; pass `-y` only when you intend to approve the action. `-o json` prints the response for `jq`. For headless use, set `HOODY_TOKEN`. See [Output formats](/foundation/cli/#output-formats). ### Find out why a command hit the wrong computer ```bash hoody local defaults get hoody config get --resolved ``` `local defaults get` shows the active profile and where each default comes from: a flag, an environment variable or the config file. `config get --resolved` shows the merged values but does not label their sources. It follows a typed `--profile`, `--config` and `--base-url`, but leaves out `--token`, `--computer`, `--realm` and `--proxy` typed on the command line. ### Tab completion in this shell ```bash source <(hoody completion bash) ``` Add the line to `~/.bashrc` to load it in every shell. In fish, use `hoody completion fish | source`; for zsh, see [Shell completion](/foundation/cli/#shell-completion). ## SSH ### The CLI from any machine ```bash ssh hoody.com # sign in from the menu; an account with a computer opens the Hub ssh "$HDY_TOKEN@hoody.com" # already signed in: HDY_TOKEN holds an hdy_ auth token ``` Opens the Hoody CLI from any SSH client, with nothing installed: a borrowed laptop, a server, a phone app. With a token as the username, you start at a prompt with the full `hoody` command. It is interactive only, and `ssh hoody.com ` is refused, so scripts use the installed CLI. A session login token is too long for an SSH username, so use an `hdy_` auth token, and a scoped one: the username shows in your process list. See [Use the CLI over SSH](/foundation/cli/#use-the-cli-over-ssh). ### Name your computers in ~/.ssh/config ```bash # ~/.ssh/config Host dev HostName {projectId}-{computerId}-ssh.{server}.computers.hoody.com User root IdentityFile ~/.ssh/hoody-dev IdentitiesOnly yes ``` Then `ssh dev`, `ssh dev 'cd /app && git pull'`, `sftp dev` and VS Code Remote-SSH all reach the computer by name. A one-off command returns its output and exit code, so it works in scripts. Add the public key to the computer first; see [SSH access](/foundation/networking/ssh/). ## What's Next - [Hoody CLI](/foundation/cli/): every global flag, profile and setting. - [Call a Bot URL](/kit/agent/bot-urls/calling/): the OpenAI, Anthropic and MCP doors, exit codes and long answers. - [SSH access](/foundation/networking/ssh/): keys, clients and SFTP. - [Hoody Kit](/kit/): the services behind each computer URL.