Automation

# Automate the loop end to end

FeatQ automation is a pull model: your agent, your keys, your schedule. FeatQ never runs code on your behalf. It exposes two authenticated HTTP endpoints, and something you control (a GitHub Action, a cron job on your VPS, or an agent session) pulls from them whenever you decide. The result of a scheduled run is a pull request in your repo, opened by your tools with your secrets, that a human reviews before anything ships.

## The two endpoints

Both use the same board key as MCP (the `fq_...` key from your board admin page) as a bearer header.

- `GET /api/v1/top-requests?limit=N` returns the board's requests ranked by current demand as JSON. Default 5, max 20. Each request is scored by votes plus half-weight comments, with the score fading as the request ages over about 90 days. Newer requests win ties.

- `GET /api/v1/top-spec` picks the current top-ranked request that is not done and returns a markdown implementation spec for it. Use `?format=json` if you want the request metadata alongside the spec text.

To read, create or update single requests, use the FeatQ [REST API](https://featq.com/docs/api).

Fetching the top spec is one command:

```
curl -fsS \
  -H "Authorization: Bearer $FEATQ_BOARD_KEY" \
  "https://featq.com/api/v1/top-spec" \
  -o spec.md
```

## Weekly GitHub Action

Save this as `.github/workflows/featq-ship.yml` in your repo. Add `FEATQ_BOARD_KEY` and `ANTHROPIC_API_KEY` as repository secrets (Settings, then Secrets and variables, then Actions). The secrets live in your repo, not with FeatQ. The example uses Claude Code, but any agent CLI that can read a markdown spec and edit files works the same way.

```
name: Ship the top feature request

on:
  schedule:
    - cron: "0 9 * * 1"   # Mondays 09:00 UTC
  workflow_dispatch: {}    # allow manual runs

jobs:
  ship-top-request:
    runs-on: ubuntu-latest
    permissions:
      contents: write
      pull-requests: write
    steps:
      - uses: actions/checkout@v4

      - name: Fetch the top-ranked spec from FeatQ
        run: |
          curl -fsS \
            -H "Authorization: Bearer ${{ secrets.FEATQ_BOARD_KEY }}" \
            "https://featq.com/api/v1/top-spec" \
            -o spec.md

      - name: Install Claude Code
        run: npm install -g @anthropic-ai/claude-code

      - name: Implement the spec on a branch
        env:
          ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
        run: |
          git config user.name "featq-automation"
          git config user.email "automation@users.noreply.github.com"
          git checkout -b featq/top-request-$(date +%Y%m%d)
          claude -p "Read spec.md in the repo root. Implement the feature it \
            describes. Verify the spec's assumptions against the actual code, \
            run the project's checks, and commit the result. Do not commit \
            spec.md itself." \
            --allowedTools "Bash,Read,Edit,Write"

      - name: Open the pull request
        env:
          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        run: |
          git push -u origin HEAD
          gh pr create \
            --title "FeatQ: implement the top-ranked request" \
            --body "Implements the current top-ranked request from our FeatQ board. Built from the spec at featq.com/api/v1/top-spec. Review before merging."
```

Every Monday the workflow pulls the top-ranked spec, has the agent implement it on a branch, and opens a PR. Merge it, close it, or edit it: nothing lands without your review. After merging, have your agent call `update_request_status` with status done so the changelog and voter emails go out.

## Same recipe on a VPS

No GitHub Actions needed. A cron entry and a shell script do the same job on any server where your repo, an agent CLI, and the `gh` CLI are available.

```
# crontab -e
# Mondays 09:00, server time
0 9 * * 1 /srv/myapp/featq-ship.sh >> /var/log/featq-ship.log 2>&1
```

```
#!/usr/bin/env bash
# /srv/myapp/featq-ship.sh
set -euo pipefail
cd /srv/myapp

# FEATQ_BOARD_KEY and ANTHROPIC_API_KEY come from the server's
# environment (for example an env file readable only by this user).

git fetch origin && git checkout main && git pull --ff-only

curl -fsS \
  -H "Authorization: Bearer $FEATQ_BOARD_KEY" \
  "https://featq.com/api/v1/top-spec" \
  -o spec.md

git checkout -b "featq/top-request-$(date +%Y%m%d)"

claude -p "Read spec.md in the repo root. Implement the feature it describes. \
  Verify the spec against the actual code, run the project's checks, and \
  commit the result. Do not commit spec.md itself." \
  --allowedTools "Bash,Read,Edit,Write"

git push -u origin HEAD
gh pr create \
  --title "FeatQ: implement the top-ranked request" \
  --body "Implements the current top-ranked request from our FeatQ board. Review before merging."
```

Keep the keys in the server's environment, readable only by the user that runs the job. Make the script executable with `chmod +x featq-ship.sh`.

## In-session agents: get_ranked_requests

When you are working interactively instead of on a schedule, the MCP tool `get_ranked_requests` gives your agent the same ranking the v1 endpoints use. Ask your agent something like "what should we build next?" and it can call:

```
get_ranked_requests({ limit: 5 })
```

The response includes each request's score and a plain-English description of the ranking, so the agent can explain its pick. From there it can call `get_request` for full context, `generate_spec` for a draft, and `update_request_status` when the work ships. Connection setup is on the [MCP page](https://featq.com/mcp) and in the [MCP reference](https://featq.com/docs/mcp).

## Honest limits

- A human reviews the PR. The automation opens pull requests; it does not merge them. Treat the agent's output like any contributor's.

- FeatQ never runs code. The endpoints return text: a ranked list and a spec. Everything that touches your codebase runs on your infrastructure with your keys.

- FeatQ never stores your repo or your AI keys. Your board key grants read access to one board and status updates on it, nothing else.

- The spec is a draft. It is built from the request, its comments, and board context, not from your code. Your agent must verify it against the actual repository.

- The top-spec endpoint is rate limited more tightly than the rest of the API because spec generation is expensive. A weekly or daily schedule is the intended use; on HTTP 429, wait for the `Retry-After` header.

---

HTML version: https://featq.com/docs/automation
Map: [llms.txt](https://featq.com/llms.txt)
