ClickUp Backfill
Scan all work items in .orchestra/work/ and ensure each has a corresponding ClickUp ticket. Create missing tickets and write the ID back into the PRD frontmatter. Do not modify ticket status.
Step 1 — Resolve Credentials
Read the ClickUp API key:
grep 'api_key:' ~/.config/workspace/bench/config.yaml | awk '{print $2}'
If not found, check CLICKUP_API_KEY env var. If neither exists, stop and tell the user.
Step 2 — Resolve List ID
Find the clickupListId for this repo:
- Determine the repo name — use
$ARGUMENTSif provided, otherwise infer from the current directory name - Read
config/projects/<repo-name>.json(relative to BENCH_ROOT, typically../..fromapps/web/or the monorepo root) - Extract
clickupListIdfrom the JSON
If no clickupListId is configured for this repo, stop and tell the user which field to add to config/projects/<repo-name>.json.
Step 3 — Scan Work Items
Use Glob to find all work item folders:
.orchestra/work/*/
Skip TEMPLATES and any folder starting with ..
For each folder, find the primary document in this order: prd.md, spec.md, README.md, first .md file found.
Read the frontmatter of the primary document and extract:
ticket— existing ClickUp ID (if present, skip this item)title— work item title (or extract from the first# Headingin the file)status— current status
Step 4 — Identify Missing Tickets
Build two lists:
- Already linked: work items with a
ticketfield in frontmatter - Missing: work items with no
ticketfield, or where the ticket field is empty
Report the count of each before proceeding.
Step 5 — Create Missing Tickets
For each work item in the Missing list:
- Extract the title and a short description (first non-heading paragraph of the PRD, or the Objective section if present)
- Create a ClickUp task:
curl -s -X POST "https://api.clickup.com/api/v2/list/<LIST_ID>/task" \
-H "Authorization: <API_KEY>" \
-H "Content-Type: application/json" \
-d '{
"name": "<title>",
"description": "<description>"
}'
- Extract the
idfield from the response - Write the ticket ID back into the primary document's frontmatter:
- If frontmatter exists: add or update the
ticket:line - If no frontmatter: prepend a frontmatter block with
ticket,status, andcreated_on
- If frontmatter exists: add or update the
Step 6 — Report
Print a summary table:
| Work Item | Action | Ticket ID | |-----------|--------|-----------| | folder-name | already linked | 86eXXXXXX | | folder-name | created | 86eYYYYYY | | folder-name | created | 86eZZZZZZ |
State how many tickets were created and how many were already linked. Do not modify ClickUp status.