What it does
- Watches a Drive folder. Checks every 10 minutes for new photos (JPEG, PNG, HEIC).
- Lists your goods with Claude. Identifies appliances, electronics, furniture, tools and vehicles, reads legible model and serial numbers, and merges the same object seen in several photos.
- Fills the official form. Importer details, classification, dates, summary lines, conveyances, and an itemized attachment with List A (accompanying) and List B (goods to follow).
- Prints the goods-to-follow list twice. One copy for the border officer to stamp, one for you.
- Never processes a photo twice. A CSV ledger records each photo's checksum with status
Already_processed; only new photos are sent to Claude. - Flags customs issues. Alcohol allowances, items that look commercial, antiques, vehicle import rules.
How it works
- You add photos to a Google Drive folder.
- The agent downloads only photos not yet in
processed_photos.csv. - Claude lists the items in each batch of photos.
- A second Claude call merges duplicates across all photos, applies your "now vs. later" rule and estimates values in CAD.
- The agent fills BSF186 and uploads
…-filled.pdf,…-goods-to-follow.pdfand the CSV ledger to the folder.
Requirements
- Docker (Docker Desktop on macOS or Windows, Docker Engine on Linux)
- An Anthropic API key with credits - platform.claude.com
- A Google account with the photos in a Drive folder, and a Google Cloud project with the Drive API enabled
- The blank form
bsf186-eng.pdffrom the CBSA website
Install
1. Get the code
git clone https://github.com/IceSkatingCoach/bsf186-agent.git
cd bsf186-agent
Or download the zip and unpack it.
2. Add the blank form
Save the CBSA form as template/bsf186-eng.pdf.
3. Configure
cp .env.example .env
cp profile.example.json profile.json
In .env set ANTHROPIC_API_KEY and DRIVE_FOLDER_ID
(the last part of the folder URL, without ?usp=sharing).
In profile.json enter your name, addresses, dates, status
(former_resident, settler or seasonal_resident), family members,
and the rule for which goods travel now and which follow.
4. Connect Google Drive
- In Google Cloud Console, enable the Google Drive API.
- Configure the OAuth consent screen, add yourself as a user, and publish the app (apps left in Testing lose their login after 7 days).
- Create an OAuth client ID of type Desktop app and save the JSON as
secrets/client_secret.json. - Sign in once:
Open the printed URL and approve. The token is stored indocker compose run --rm -p 8765:8765 agent python agent.py authdata/token.json.
5. Run
# one check, to test
docker compose run --rm agent python agent.py once
# keep running in the background, checking every 10 minutes
docker compose up -d --build
docker compose logs -f
Files the agent writes
| File | Where | Contents |
|---|---|---|
<prefix>-filled.pdf | Drive folder | BSF186 plus itemized List A and List B |
<prefix>-goods-to-follow.pdf | Drive folder | Two copies of List B with a box for the CBSA stamp |
processed_photos.csv | Drive folder and data/ | filename, md5, Drive file id, status, processed_at |
extracted_items.json | data/ | Items found per photo, reused when new photos arrive |
To re-read a photo, delete its row from data/processed_photos.csv.
To start over, also delete data/extracted_items.json.
Privacy and cost
- Runs on your own computer. Photos go only to Google Drive and to the Anthropic API.
- Your personal details stay in
profile.jsonand.envon your machine; both are excluded from git. - A first run of about 75 photos costs roughly US$1-3 in API credits. Later runs send only new photos.
Important
This is not a CBSA product. Values are estimates and the item list comes from photos, so review every line, add serial numbers, and correct quantities before you sign. Remove the "Notes for importer" section before submitting. Vehicles must also meet Transport Canada import rules.