---
name: enrich-zotero-abstracts
description: Use when the user wants to fix or fill in missing Zotero abstracts, when they say "fix abstracts", "fill missing abstracts", "/zotero-context:enrich-zotero-abstracts", or when reviewing items with thin abstractNote fields
allowed-tools: |
  Bash(.zotero-context/bin/search_items.py *)
  Bash(.zotero-context/bin/enrich_abstract.py *)
  Read
  WebSearch
  WebFetch
disable-model-invocation: true
---

# Enrich Zotero Abstracts

## Overview

Find Zotero items with empty or short abstracts in the configured libraries, web-search for plausible abstract content, present each candidate to the user for approval, and write back to Zotero with version-conflict protection. Items updated this way receive a `claude-enriched-YYYY-MM-DD` tag for traceability.

## When to Use

- User says "fix abstracts", "fill missing abstracts", "/zotero-context:enrich-zotero-abstracts"
- User wants to make a library more useful for downstream search

## Prerequisites

- `/zotero-context:setup-zotero-references` has been run in this repo (`.zotero-context/config.json` exists).
- `ZOTERO_API_KEY` with **write** scope is set in `.env` — the local Zotero API is read-only for item modification.

## Workflow

### Step 1: List candidates

```bash
.zotero-context/bin/search_items.py --no-abstract --limit 50 --output summary
```

This returns items where `abstractNote` is missing or shorter than 50 characters, as a JSON summary with `title`, `creators`, `year`, `DOI`, `url`, `abstract`, and `tags` fields.

### Step 2: For each candidate (one at a time)

Show the user:

```
Title: <title>
Authors: <creators>
Year: <year>
DOI/URL: <doi or url>
Current abstract: <abstractNote, "(empty)" if blank>

Search the web for an abstract? [y/n/skip-rest]
```

If yes, web-search using DOI > URL > "title authors year" as the anchor. Quote a candidate abstract back to the user (clearly attributed to the source).

```
Proposed abstract (from <source URL>):

<text>

Apply this to the Zotero item? [y/edit/n]
```

If `edit`, let the user revise inline. If `y`, proceed to Step 3.

### Step 3: Apply

```bash
.zotero-context/bin/enrich_abstract.py \
    --key <key> \
    --abstract "<text>" \
    --lib <library id> \
    --type {user|group}
```

Watch for the result:

- `{"status":"ok",...}` — success.
- `{"status":"conflict",...}` — the item changed in Zotero between scan and PATCH. Refetch and ask the user whether to retry with the latest data.

### Step 4: Report

After all candidates, summarize: N attempted, M enriched, C conflicts, S skipped. List the keys that received the `claude-enriched-YYYY-MM-DD` tag.

## Common Mistakes

- Inventing abstracts from training data instead of web-searching for sourced text. **Every proposed abstract must be attributable to a URL.**
- Running with `--dry-run` for production usage. Dry-run is for verifying the payload only.
- Bulk-applying without per-item user approval. The user must consent to each enrichment.
- Forgetting that `ZOTERO_API_KEY` needs write scope; a read-scope key fails on PATCH.

## Verification After Run

After enrichment, the user should see in Zotero (web or desktop):

- Updated `abstractNote` field on each enriched item.
- New tag `claude-enriched-YYYY-MM-DD` on each enriched item.
- No changes to other fields.
