Skip to content

feat(candidate-db): add data folder, checked import, tags, CRUD and search - #13

Merged
codeotter0201 merged 1 commit into
mainfrom
feat/issue-1-candidate-db
Nov 7, 2026
Merged

codeotter0201 merged 1 commit into
mainfrom
feat/issue-1-candidate-db

Conversation

@codeotter0201

Copy link
Copy Markdown
Owner

Summary

Implements the candidate database from #1: Data folder, Sources, structured Facts, quality check, follow-up questions, inferred Facts, Tags from a shared Taxonomy, CRUD, and a rebuildable Index with search.

  • skills/headhunter/scripts/hh.py: helper CLI for the fixed operations: init, candidate new|list|show|archive|restore, source add|github|state, fact add|update, next-id, import-report, questions, extract-text, taxonomy find, validate, index, search candidates|facts, query
  • skills/headhunter/scripts/hhyaml.py: reads and writes the YAML subset the Data folder uses, with line-numbered errors for anything outside it
  • skills/headhunter/assets/taxonomy.yml: starter Taxonomy, 153 Tags in 8 dimensions with Chinese and English labels and aliases, copied to <data>/taxonomy.yml on first use
  • skills/headhunter/SKILL.md: layout, file formats and the agent workflows (import with quality check, Import report, follow-up questions, inferred Facts, conflicts, tags, search)
  • CONTEXT.md: defines Import report, Tag and Taxonomy; Source and Fact now mention evidence levels, inferred Facts and ids
  • README.md / README.zh-TW.md: Candidate database feature and the Python requirement
  • .gitignore: ignores __pycache__/

Related Issues

Closes #1

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Data layout change (existing data folders need migration)
  • Documentation update
  • Refactoring (no functional changes)

Decisions

Item Decision Rejected alternatives
How <slug> is formed The name as given, NFC-normalized and lowercased, spaces to hyphens, punctuation removed; Chinese characters kept (c-001-王小明) Romanization: needs a dependency and is ambiguous for Taiwanese names. Id only: folders become unreadable to people
Scripts runtime and dependencies Python 3.9+ standard library only; one CLI (hh.py) PyYAML: not installed by default. Node.js: less common on user machines. Shell + sqlite3: cannot parse YAML reliably
YAML without PyYAML Bundled reader/writer for a documented subset; output stays valid YAML and was checked against PyYAML JSON files: harder for people to read and edit. Full YAML parser: far larger than the files need
Starter Taxonomy 153 Tags across skill, tool, domain, industry, function, seniority, language and soft-skill, aimed at the Taiwan tech job market; validation forbids a label or alias belonging to two Tags Free-form tags; a much larger catalog that users would have to prune
Ids Zero-padded, assigned by the script: c-001, s-001, f-001, q-001 Unpadded ids, which sort badly as files
Fact evidence level Computed by the script as the strongest evidence of the cited Sources; inferred Facts have none until confirmed Agent-written evidence, which can drift from the Sources
Writing Facts fact add / fact update take JSON or YAML on stdin, assign ids, and write nothing if any check fails; hand edits are allowed and validate checks them Agent edits facts.yml directly with no gate
Follow-up questions Checklist lines in Import reports (- [ ] q-004: ...), parsed by the script to list open ones A separate questions file that duplicates the report
Index freshness Searches rebuild index.sqlite when any Data folder file is newer; index always deletes and rebuilds Rebuilding on every search; manual rebuilds only
A Fact with no fitting Tag Waits in the Import report next to its proposed Tag and is written once the user decides Writing it untagged, which breaks "every Fact has Tags"

Migration

No released version has created a Data folder (skills/headhunter/SKILL.md had only the skeleton and no scripts), so there are no existing Data folders to migrate. On first run, init (or any other command) creates the layout and the starter Taxonomy, and never overwrites existing files.

Validation

All runs used fictional Candidates, 王小明 (c-001) and 林小華 (c-002), with HEADHUNTER_DATA_DIR set to a scratch folder outside any repository. The scripts ran on Python 3.9 (the oldest supported version) and again on Python 3.13. I acted as the agent following SKILL.md: I read each Source, wrote the Facts and Import reports, and simulated the user's answers.

Data folder

  • HEADHUNTER_DATA_DIR=<a folder inside a fresh git repo> hh.py init → error: the Data folder ... is inside the git working tree ..., exit 1
  • HEADHUNTER_DATA_DIR=<inside this plugin folder> hh.py init → refused with the plugin-folder message, exit 1
  • hh.py init twice → first: Created: ..., candidates/, jobs/, companies/, archive/, taxonomy.yml; second: Already set up; nothing changed.

Create and import every kind of Source

  • candidate new --name 王小明 --name-en "Hsiao-Ming Wang" → c-001; candidate new --name 林小華 ... → c-002
  • c-001: note (source add ... --type note), work log, PDF resume, certificate photo (--evidence documented), GitHub repository (source github c-1 codeotter0201/headhunter-agent), and an interview Source from stdin
  • c-002: Word resume (read with extract-text), note, an unknown binary file (--type other, recorded as unreadable with source state, content not guessed), and an interview Source
  • extract-text <pdf> without pdftotext installed → error telling the agent to read the PDF itself; the PDF and the photo were read with the agent's own file reading
  • A GitHub profile import was also checked against an organization account (source github c-1 https://github.com/cli), and a missing repository → gh: Not Found (HTTP 404), exit 1

Quality check, conflicts, follow-up questions, inference

  • Missing fields recorded per Fact (for example f-002: when, who, result), vague lines rejected with reasons ("很會溝通…", "最近在研究一些新技術")
  • Contradictions: team size 3 (work log) vs 5 (resume) for c-001; start date 2019 (note) vs 2020-03 (resume) for c-002 → both Facts set to conflict, candidate show lists Conflicts waiting for the user, years of experience excludes conflicting Facts
  • Answers saved as interview Sources; resolved Facts cite at: q-00N; losers set to superseded with superseded_by; answered questions checked off in their reports
  • Unanswered questions (c-001 q-007, c-002 q-004) still listed by questions afterwards
  • Inferred Facts (origin: inferred, derived_from, reasoning) shown as inferred, unconfirmed, excluded from search candidates (--tag devops → No matching Candidates.), then confirmed (fact update ... {"origin": "sourced", "sources": [...]}) → matched afterwards
  • Proposed Tags skill/computer-science and tool/looker-studio added to taxonomy.yml only after the simulated acceptance; the waiting education Fact was written afterwards

Validation gate

  • fact add with an unknown Tag and no Source → nothing written: with both errors
  • validate caught a real mistake during the run: an unquoted comma in a one-line glossary mapping (line 1: expected ':' in flow mapping)
  • Final validate → OK: taxonomy.yml and 2 Candidate folder(s) are valid. on Python 3.9 and 3.13

Index and search

  • search candidates --tag python --industry finance --min-years 5 → only c-002 林小華 (active, mid, 7.4 years), with matched Facts per Tag
  • Also ran: --tag kubernetes, --tag 後端 --seniority senior, --tag "google data studio" (alias), --tag 資訊工程 (Chinese alias), search facts --evidence documented, --tag etl --since 2023, --kind education, --state superseded, a query on candidate_tags, and questions
  • Deleted index.sqlite, ran index, repeated all 12 commands → diff of the outputs is empty
  • query "DELETE FROM facts" → attempt to write a readonly database, exit 1

Archive and restore

  • candidate archive c-1 → gone from search candidates --tag kubernetes and candidate list, shown by candidate list --archived; fact update c-1 ... → error: c-001 is archived
  • candidate restore c-1 → back in both

Repository checks

  • claude plugin validate . → passed
  • claude plugin validate .claude-plugin/plugin.json → passed with the expected warning that CLAUDE.md at the plugin root is not loaded as plugin context
  • hhyaml against PyYAML on a sample with nested lists, flow collections, quoted strings, block scalars and comments → identical results, and dumped output parses the same in both; rejected inputs (anchors, tabs, duplicate keys, a: b: c, unterminated flow) fail with line numbers. Ran on Python 3.9 and 3.13
  • skills/headhunter/assets/taxonomy.yml parsed identically by PyYAML and hhyaml; validate_taxonomy finds no errors
  • SKILL.md frontmatter parses with keys name and description; both plugin manifests parse as JSON
  • ruff check --select E,F,W,B skills/headhunter/scripts → all checks passed

Not run

  • Loading the skill in a fresh session with claude --plugin-dir . and letting that session drive the workflow; the walkthrough ran the scripts directly while I followed SKILL.md
  • extract-text on a PDF with pdftotext installed (not installed here)
  • Windows

Checklist

  • No real candidate data in code, examples, fixtures, screenshots or this PR
  • skills/headhunter/SKILL.md, README.md and README.zh-TW.md updated when behavior or data layout changed
  • Migration for existing data folders described (data layout changes only)
  • Self-review completed
  • Documentation updated (if needed)

🤖 Generated with Claude Code

…earch

Implement the candidate database from issue #1. A stdlib-only helper
script (skills/headhunter/scripts/hh.py) creates the Data folder, assigns
ids, keeps raw Sources, writes Facts with validation, archives and
restores Candidates, and builds and queries a rebuildable SQLite Index.
A bundled YAML subset reader/writer (hhyaml.py) keeps the files readable
without third-party packages.

SKILL.md describes the file formats and the import workflow the agent
follows: quality check, Import report, follow-up questions saved as
interview Sources, inferred Facts that need confirmation, conflicts, and
Tags from a starter bilingual Taxonomy. CONTEXT.md defines Import report,
Tag and Taxonomy; both READMEs describe the feature and the Python
requirement.

Closes #1

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added area/agent-instructions AGENTS.md, CLAUDE.md, CONTEXT.md and skill instructions area/docs README and contributor documentation type/feature New functionality labels Nov 7, 2026
@codeotter0201
codeotter0201 merged commit f316776 into main Nov 7, 2026
1 check passed
@codeotter0201
codeotter0201 deleted the feat/issue-1-candidate-db branch November 7, 2026 18:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/agent-instructions AGENTS.md, CLAUDE.md, CONTEXT.md and skill instructions area/docs README and contributor documentation type/feature New functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] Candidate database: import, quality check, tags, CRUD and search

1 participant