Skip to content

Add agent-friendly research CLI + research skill#1

Open
sherrymao wants to merge 1 commit into
mainfrom
feat/research-cli-skill
Open

Add agent-friendly research CLI + research skill#1
sherrymao wants to merge 1 commit into
mainfrom
feat/research-cli-skill

Conversation

@sherrymao

Copy link
Copy Markdown
Owner

Summary

  • scripts/cli.py — unified agent-friendly CLI wrapping the existing research workflow. Subcommands: fetch, cron, candidates (list/update/delete), ingest, papers (list/delete), validate, status, report. Global --json flag for machine-readable output (in JSON mode, library progress prints are suppressed so stdout is pure JSON).
  • .claude/skills/research/SKILL.md — project-level Claude Code skill. Auto-loads in any Claude Code session opened in this repo. Wraps python -m scripts.cli so an agent can drive the full research loop without starting the Flask server.
  • tests/test_cli.py — 16 hermetic tests covering dispatch, --json emission, candidates update/delete, and the cron --ingest round with fetch_arxiv mocked.
  • Makefile — added make research CMD='...' target as a passthrough to the CLI.
  • README.md — added the research skill to the Claude Code Integration section.
  • CLAUDE.md — three additions: validation vocabularies, score field layering, gitignore boundary.

Why

Before: fetch.py / ingest.py had argparse CLIs but only emitted human text; validate.py / report_html.py had no arg CLI; candidates update/delete and the rest of the write paths were only on Flask /api/* — so an agent had to make serve and go through HTTP. The CLI + skill collapses that to a single, reusable surface.

Design

  • Facade, not rewrite: imports and reuses fetch_arxiv / write_candidates / load_candidate_file / ingest_file / delete_papers / validate_all / generate_html_dashboard / filter_papers / load_all_papers. Old __main__ blocks and make fetch / make ingest / make validate / make html keep working unchanged.
  • Candidates update/delete operate on YAML files directly (not on the server's process-local _pending_candidates), so they work without Flask running.
  • cron is one round of fetch + optional auto-ingest — designed to be invoked repeatedly by ScheduleWakeup or external schedulers, not a system crontab itself.
  • --json is a global flag, placed before the subcommand. In JSON mode the handler runs inside contextlib.redirect_stdout(StringIO()) so library progress prints don't pollute stdout — agents can parse the output directly.

Verification

  • python -m scripts.cli --help lists all subcommands.
  • python -m scripts.cli --json fetch --direction post_training --days 30 --limit 5 → valid JSON with count / file / papers.
  • python -m scripts.cli --json candidates list / update / delete work on output/candidates/*.yaml.
  • python -m scripts.cli --json cron --direction post_training --days 7 --ingest → one fetch + ingest round, JSON summary.
  • python -m scripts.cli --json papers list / validate / status / report work.
  • make test is green for the new tests/test_cli.py (pre-existing 2 test_briefing.py failures are unrelated; present on a clean checkout of main).

Not in this round

Notes / notebooks / score-adjustment / briefing / notebooklm stay on the Flask web UI or direct store modules. The CLI is structured around a subcommand registry so each can be added in a follow-up without touching the dispatch layer.

Wrap the core research loop (fetch → review candidates → ingest → validate
→ report) into a unified `python -m scripts.cli` with `--json` machine output,
plus a `cron` subcommand for scheduled fetch rounds. The CLI reuses existing
functions (fetch_arxiv, ingest_file, delete_papers, validate_all, etc.) and
does not replace the per-script __main__ entry points or Makefile — backward
compatible.

Ship a project-level `research` skill (.claude/skills/research/) so any Claude
Code session in this repo auto-loads an agent-pluggable entry to the whole
workflow without starting the Flask server. Covers the minimal core loop;
notes/notebooks/score/briefing/notebooklm deferred to a second round via the
subcommand registry.

- scripts/cli.py: unified CLI (fetch/cron/candidates/ingest/papers/validate/status/report)
- .claude/skills/research/SKILL.md: xhs-research-style skill with command quick-ref
- tests/test_cli.py: 16 tests (dispatch, --json, candidates file r/w, cron --ingest)
- Makefile: `make research CMD=...` passthrough
- README.md + CLAUDE.md: document the skill + prerequisites

Co-Authored-By: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant