pragma-gtm.com

Work sample

Job search engine: a daily scan and the board it feeds, for any job title.

A job search tool built on invented data and replayed over two weeks. Every morning it reads the job boards, proves each role on the company's own list, drops what can never work and scores the rest with a fit line anyone can read. The board then tracks applications, CVs, live processes ranked by preference and the decisions the outcomes point to. The rules sit in a profile file: shown here for a Customer Success Manager in Berlin and a Data Analyst in Amsterdam, on the same engine.

Daily scanDedupeProof on ATSGatesFit scoringJob boardCV checksPython
Designed and builtDaily scan, gates, fit line, board, CV check. Rules are mine; Claude Code wrote the code from them.
Designed, not runningLive sources and paid data tools.

Two weeks of the scan

Most of the work is saying no early and saying why. Out of 47 new Customer Success roles, 4 were worth a tailored CV.

422board copies read in 14 runs
47new roles in the profile's titles
28dropped by a gate before scoring, each with the reason
4worth applying, 3 of them with a CV drafted

The board

Built by the engine after the fortnight. Click the tabs: applications, open roles, CVs, live processes ranked by preference, decisions and the run log.

Open the board full screen · the same board for the Data Analyst profile

One run, every morning

DiscoverBoard copies first seen since the last run. Tier A sources every run, tier B weekly, tier C monthly. A rerun under 20 hours after the last one is skipped.
DedupeOne row per company and title. A role an earlier run handled is not scored again when a slower board picks it up (31 copies in two weeks).
ProveOnly the company's own list decides. Gone from the list means closed, whatever the boards show. Unreadable means "could not verify", never closed on a guess.
Gate and scoreDrop what can never work, with the reason. Score the rest: role fit first, then location and the factors, written out as a fit line.
RecheckEvery tracked role is read again on its company's list. 2 closed during the fortnight, one after the application went in.
StepRoles
Board copies read422
New roles in the profile's titles47
Closed on the company's own list, still on a board1
Dropped by a gate28
Seen, not a fit (role fit under 6.5)4
Could not verify1
Below the 8 bar, listed for reference9
Worth applying: fit 8 or more, CV brief and a note to a named person4

The gates: no score for a role that cannot work

ReasonDropped
Needs a move inside the home country, no remote option9
Outside the regions the profile works in (US remote, London, Paris)8
None of the duties the profile wants to do (support desks, cold prospecting)6
A local language the profile does not have (Dutch, Spanish)5

The fit line

Every score is written out, so a high number can be questioned and a low one explained. Role fit comes first and never moves; the factors sit next to it.

fit 8 (role 7, remote in home country +1.5, pay not stated (ask), startup minus 0.5)

PartRule
Role fit, 0 to 10Title (target or adjacent), share of the duties you want against the ones you avoid, tools on record against tools asked, minus 0.5 when the years asked sit 2 or more above your record, minus 1 for a title above what you have held
LocationPoints per place from the profile: home city, remote in the home country, EU remote, each relocation city
PayBand top under your floor minus 1.5, floor inside the band 0, band bottom above the floor plus 0.5, not stated: ask
Office and companyOn site only minus 0.5; startup under 150 people minus 0.5; a role light on the duties you want at 300+ people minus 0.5
ShowRole fit under 6.5 is never a recommendation, whatever the location adds. Total 8 or more gets a CV brief and a note; with live interviews running, a CV only from 8.5

What the board adds

TabRule
ApplicationsEvery application with its stage. Waiting over 21 days with no human reply becomes "no reply". A call whose feedback date passed gets a follow up draft, sent only after a yes
CVsScore on the rubric (target 9, floor 8), the channel that received it, whether a note went to a named person, and the outcome. A CV that was sent is never edited again
Salary & companiesLive processes ranked by a preference score: salary 30%, safety 25%, remote 20%, role fit 15%, product 10%. A number the company confirms replaces any estimate
DecisionsWhat the outcomes show, written as a yes or no question. A yes changes a rule in the next scan. Under a 10 point gap, or under 10 outcomes, the board says it is too early to act
ScansOne line per run: copies read, new roles, what was kept, what closed, CVs drafted, and skipped runs with the reason

13 calls from 113 applications, about 1 in 9, which is in line with what tailored applications get. Over half had no human reply after 21 days. Only one decision clears the bar: companies under 150 people called back 15% of the time, companies over 500 only 4%, so cold applications to big companies now need a role built around the profile's core duties. A note to a named person (19% against 10%) and roles built around the core duties (14% against 8%) stay open: the gaps are under 10 points.

Same engine, another job title

A new search is a new profile: target and adjacent titles, the duties you want and the ones you avoid, tools on record, languages, home city, regions, location points, pay floor and years on record. Nothing in the engine changes.

ResultCustomer Success, BerlinData Analyst, Amsterdam
New roles in the profile's titles4753
Dropped by a gate2831
Main gate reasonmove, no remote (9)German C1 (13)
Listed for reference911
Worth applying47

The Customer Success profile speaks German, so German roles pass; the Data Analyst profile does not, so German C1 is its biggest gate. The Data Analyst profile is open to moves, so a Berlin or London role scores on its merits instead of dropping.

The CV check

Every role at 8 or more gets a brief: the headline (the JD title, for the ATS), the top 3 needs, the keywords on record, the gaps to name rather than cover, the location line and how the ATS reads the file. Then the check runs the tailoring rules on the CV against the posting.

Rubric partDraftFixed
ATS: JD title in the headline, keyword coverage02
Proof: a bullet with a number for each top need02
Wording: at most one phrase lifted from the ad12
Writing: pronouns, hedges, dashes, filler, repeated verbs, one line bullets02
Automatic part, of 8 (focus is left to a person)18
Draft1 of 8 Fixed8 of 8
Sample Candidate
Berlin, Germany | candidate@example.com | linkedin.com/in/sample-candidate
1Customer Success Manager | Renewals, Expansion and Churn Prevention
2Customer Success Manager who protects and grows a mid market book, with 4 years in SaaS on Salesforce, HubSpot and Intercom.
SKILLS
3Salesforce, HubSpot, Intercom, Gainsight, renewals, expansion, churn risk, success playbooks, health scores
WORK EXPERIENCE
Customer Success Manager | Example Software GmbH | Jan 2023 to Present
4Renewals: Renewed 92% of a 60 account book (1.4M ARR) and grew expansion revenue 18% in Salesforce.
Churn: Ran monthly churn risk reviews in HubSpot that cut logo churn 4 points in a year.
Playbooks: Wrote 3 success playbooks in Intercom that every new customer now follows.
5Escalations: Resolved 40 escalations a quarter with product, keeping 9 of 10 at risk accounts.
Account Executive | Example Media GmbH | Mar 2019 to Dec 2022
Quota: Closed 35 new business deals and finished at 103% of quota.
EDUCATION
BA Business, Example University
  1. 1Headline is the JD title. The draft said Account Manager, so a title match in the ATS missed.
  2. 2Summary rewritten. The pronoun and "passionate" are gone; the tools on record are named instead.
  3. 3Skills carry the JD tools used in the job. HubSpot and Intercom added, each also in a bullet. Zendesk stays out: never used, so it is a gap to name.
  4. 4A number for each top need. Renewals and expansion, churn risk reviews and success playbooks each have a bullet with a result.
  5. 5Writing fixed. "About" before a number, a dash and "responsible for" removed; the escalation bullet now has scope.

Highlighted terms come from the posting. Bold figures are the proof. Invented candidate.

The fixed CV still misses Zendesk. The candidate never used it, so it is named as a gap, not written in.

The draft's fix list
CV check against: Customer Success Manager
Keywords: 4 of 7 covered; missing: Zendesk, Intercom, HubSpot
Rubric: ATS 0, proof 0, wording 1, writing 0, focus (set by a person)
Automatic part: 1 of 8. Bar: 9 of 10 overall, never deliver under 8.
Fix list:
  - Headline should start with the JD title "Customer Success Manager" (now: "Account Manager | SaaS and Customer Relationships")
  - Put "Salesforce" in both SKILLS and a bullet (skills True, bullet False)
  - No bullet with a number proves "success playbooks"
  - No bullet with a number proves "renewals expansion"
  - No bullet with a number proves "churn risk reviews"
  - 2 phrases lifted from the JD, keep at most one: ['lead churn risk reviews', 'own renewals and expansion']
  - line 4: pronoun
  - line 4: filler "passionate"
  - line 12: hedge before a number
  - line 13: dash used as punctuation
  - line 14: filler "responsible for"
  - line 13: no number or scope
  - line 14: no number or scope
The fixed CV (invented candidate)
Sample Candidate
Berlin, Germany | candidate@example.com | linkedin.com/in/sample-candidate
Customer Success Manager | Renewals, Expansion and Churn Prevention
Customer Success Manager who protects and grows a mid market book, with 4 years in SaaS on Salesforce, HubSpot and Intercom.

SKILLS
Salesforce, HubSpot, Intercom, Gainsight, renewals, expansion, churn risk, success playbooks, health scores

WORK EXPERIENCE
Customer Success Manager | Example Software GmbH | Jan 2023 to Present
- Renewals: Renewed 92% of a 60 account book (1.4M ARR) and grew expansion revenue 18% in Salesforce.
- Churn: Ran monthly churn risk reviews in HubSpot that cut logo churn 4 points in a year.
- Playbooks: Wrote 3 success playbooks in Intercom that every new customer now follows.
- Escalations: Resolved 40 escalations a quarter with product, keeping 9 of 10 at risk accounts.
Account Executive | Example Media GmbH | Mar 2019 to Dec 2022
- Quota: Closed 35 new business deals and finished at 103% of quota.

EDUCATION
BA Business, Example University

What a production version adds

PartIn this sampleIn production
Schedule14 replayed daysA scheduled task every morning plus manual runs; the 20 hour skip rule protects paid credits
Sources8 invented boards in three tiersJob boards, VC portfolio boards and ATS host searches in tiers, each with a yield column; a board moves up when it finds a role that passes, down after 4 empty checks; blocked sources are never worked around
Data toolsNot neededFree sources first, paid last: web search and fetch, then search APIs within a monthly budget, contact data tools for the named person, and the most expensive enrichment only when nothing else found them
ProofAn open and close day per postingThe company's ATS feed or careers page read live; aggregator copies are discovery only
RulesTwo profile filesStanding rules written down as they are decided, each with the date and the reason
CV and noteA brief and a checkerThe CV built on a template from confirmed facts only, then checked; a note under 100 words to a named person

How it was built

I did
Every rule: the gates, the fit parts and their weights, the show bar, the preference weights, the decision threshold and the CV rubric, each one a setting in the profile or a check in the code.
AI did
Claude Code wrote the scripts from those rules. No model scores a role during the run.
Checks
The run stops if an unverified role, a role under the show bar or a done story reaches the list, if a role under 8 gets a CV brief, or if a role is reported twice.
Run it
python3 make_synthetic_jobs.py, python3 scan.py profiles/customer-success.json --out output/customer-success, then python3 board.py profiles/customer-success.json output/customer-success. Standard library only.

Synthetic input. Every company, posting, candidate and application is invented to exercise the rules, and the application history has its odds built in, so the decisions show how the board reasons, not a finding. Links end in .example.

Files

The whole folder on GitHub: clone it and run it with plain Python.

scan.pyThe daily run: dedupe, proof, gates, fit line, recheck.
board.pyApplications, CVs, preference score, decisions, run log.
check_cv.pyThe tailoring rules run on a CV against one posting.
make_synthetic_jobs.pyBuilds the invented postings, board copies and history.
profiles/customer-success.jsonRules for a Customer Success Manager search.
profiles/data-analyst.jsonRules for a Data Analyst search.
output/customer-success/board.htmlThe board for the Customer Success profile.
output/data-analyst/board.htmlThe board for the Data Analyst profile.
output/customer-success/summary.jsonCounts behind every number on this page.
data/postings.json659 invented postings with open and close days.
data/board_copies.json1,268 invented board copies.
README.mdHow to run it and what is real.
Read scan.py here
"""
Job search engine: a daily scan that finds roles, proves they are open, scores
them honestly and keeps a board. The rules live in a profile file, so the same
engine runs for any job title.

    python3 scan.py profiles/customer-success.json --out output/customer-success
    python3 scan.py profiles/data-analyst.json --out output/data-analyst

It replays 14 days of the scheduled scan (every morning, plus one manual
evening rerun). Every run:
  0. Skip rule: if the last run started under 20 hours ago, do nothing.
  1. Discover: read the board copies first seen since the last run. Tier A
     sources every run, tier B weekly, tier C monthly.
  2. Dedupe: one row per company and title (a role posted in two cities or
     reposted under a new id collapses into one), and a role an earlier run
     already handled is not scored again when a later board picks it up.
  3. Prove: only the company's own job list decides. Gone from the list means
     closed, whatever the boards still show. A list that cannot be read is
     "could not verify", never closed on a guess. No list of its own: "board only".
  4. Gate (dropped with a reason, never scored): junior or student role, a
     language the profile does not have, a region it does not work in, a move
     inside the home country with no remote option, a company that rejected
     it before, none of the wanted duties.
  5. Role fit 0 to 10: title, share of wanted duties, tools on record against
     tools asked, years asked above the record, a title above the record.
  6. Fit line: role fit plus location points, then pay, office, startup and
     "light on wanted duties" factors, each written out.
  7. Show: role fit under 6.5 is "seen, not a fit". Total 8+ is "worth
     applying" (9+ "strong fit") and gets a CV brief and a note to a named
     person; while interviewing, a CV is drafted only from 8.5.
  8. Recheck: every tracked role is read again on its company's list.
After the fortnight: board.json, summary.json and the run log.
board.py turns them into the board. Standard library only.
"""
import argparse
import json
import os
import re
from collections import Counter, defaultdict

DAYS = 14
TIER_EVERY = {"A": 1, "B": 7, "C": 30}
SCHEDULE = [(d, 7.75, "scheduled") for d in range(DAYS)] + [(5, 20.5, "manual rerun")]
ATS_PATTERNS = [
    ("ashbyhq", "Ashby", "AI assisted screening checks each requirement: mirror the JD's skill and tool terms in skills and in bullets."),
    ("greenhouse", "Greenhouse", "Parsed into fields and searched by keyword: exact terms and standard headings."),
    ("lever", "Lever", "No stemming, one profile per company: exact terms, identical facts across applications."),
    ("personio", "Personio", "Plain text conversion: simple layout, extractable text, the ad's language."),
    ("teamtailor", "Teamtailor", "An AI summary is written against the JD: name every required skill near the top."),
    ("join.", "JOIN", "Small companies, fast human read: the top third has to answer the JD."),
    ("recruitee", "Recruitee", "Reliable parser plus screening questions: answer knockout questions carefully."),
    ("workable", "Workable", "Parsed profile and screening questions: standard headings, exact terms."),
]


def half(x):
    return round(x * 2) / 2


def norm_title(t):
    t = re.sub(r"\b(senior|sr|founding|junior)\b", "", t.lower())
    return re.sub(r"\s+", " ", t).strip()


def ats_of(url):
    for key, name, advice in ATS_PATTERNS:
        if key in url:
            return name, advice
    return "Unknown", "Check how the application is received before building the CV."

# ---- rules -------------------------------------------------------------------


def title_scope(title, P):
    t = title.lower()
    if any(x.lower() in t for x in P["target_titles"]):
        scope = "target"
    elif any(x.lower() in t for x in P["adjacent_titles"]):
        scope = "adjacent"
    else:
        return "out"
    if any(re.search(rf"\b{re.escape(w.lower())}\b", t) for w in P["drop_titles"]):
        return "drop"
    return scope


def duty_share(duties, P):
    core = sum(1 for d in duties if any(w.lower() in d.lower() for w in P["core_duties"]))
    avoid = sum(1 for d in duties if any(w.lower() in d.lower() for w in P["avoid_duties"]))
    return core, avoid


def gate(r, P, scope):
    if scope == "drop":
        return "junior, intern or student role"
    missing = [l for l in r["languages_required"] if l not in P["languages"]]
    if missing:
        return f"{', '.join(missing)} required"
    if r["country"] not in P["work_regions"]:
        return "outside the regions you work in"
    if r["company"] in P["rejected_before"]:
        return "rejected there before, done story"
    if (P["no_moves_inside_home_country"] and r["country"] == P["home_country"]
            and r["workplace"] != "remote" and r["location"] != P["home_city"]):
        return "needs a move inside the home country, no remote"
    if P["drop_when_no_core_duties"] and duty_share(r["duties"], P)[0] == 0:
        return "none of the duties you want to do"
    return None


def role_fit(r, P, scope):
    base = 4.0 if scope == "target" else 2.5
    core, avoid = duty_share(r["duties"], P)
    share = core / max(core + avoid, 1)
    have = set(r["tools"]) & set(P["tools"])
    missing = len(r["tools"]) - len(have)
    fit = base + 3 * share + 2 * len(have) / max(len(r["tools"]), 1) - min(0.75 * missing, 1.5)
    if r["years_required"] >= P["years_on_record"] + 2:
        fit -= 0.5
    above = any(r["title"].startswith(s) for s in P["senior_titles_above_record"])
    if above:
        fit -= 1
    return max(0, min(half(fit), 10)), share, above


def location_points(r, P):
    L = P["location_points"]
    if r["location"] == P["home_city"]:
        return L.get("home city", 0), "home city"
    if r["location"] == f"Remote {P['home_country']}":
        return L.get("remote home country", 0), "remote in home country"
    if r["location"] == "Remote EU":
        return L.get("remote EU", 0), "EU remote"
    if r["location"] in L:
        return L[r["location"]], r["location"]
    return 0, f"{r['location']} needs a move"


def fit_line(r, P, rf, share):
    parts = [f"role {rf:g}"]
    pts, label = location_points(r, P)
    total = rf + pts
    parts.append(f"{label} +{pts:g}")
    if r["pay_k_eur"]:
        lo, hi = r["pay_k_eur"]
        if hi < P["pay_floor_k_eur"]:
            total -= 1.5
            parts.append("pay below floor minus 1.5")
        elif lo >= P["pay_floor_k_eur"]:
            total += 0.5
            parts.append("pay above floor +0.5")
        else:
            parts.append("floor inside the band")
    else:
        parts.append("pay not stated (ask)")
    if r["workplace"] == "on site":
        total -= 0.5
        parts.append("on site only minus 0.5")
    if r["employees"] < 150:
        total -= 0.5
        parts.append("startup minus 0.5")
    if share < 0.5 and r["employees"] >= 300:
        total -= 0.5
        parts.append("light on wanted duties at a big team minus 0.5")
    total = max(0, min(half(total), 10))
    return total, f"fit {total:g} ({', '.join(parts)})"


def brief(r, P):
    have = [k for k in P["cv_keywords_on_record"] if any(k.lower() in t.lower() for t in r["tools"] + r["duties"])]
    gaps = [t for t in r["tools"] if t not in P["cv_keywords_on_record"]]
    if r["years_required"] >= P["years_on_record"] + 2:
        gaps.append(f"{r['years_required']} years asked")
    ats, advice = ats_of(r["url"])
    loc = f"{P['home_city']}, {P['home_country']}" + ("" if r["location"] == P["home_city"] else
                                                      " (open to remote)" if r["workplace"] == "remote" else " (open to relocation)")
    return {"headline": r["title"], "top_requirements": r["duties"][:3], "keywords_on_record": have,
            "gaps_to_name_not_cover": gaps, "location_line": loc, "ats": ats, "ats_advice": advice}


def is_open(p, day):
    return p["opened_day"] <= day and (p["closed_day"] is None or day < p["closed_day"])

# ---- one run -------------------------------------------------------------------


def run(day, last_day, P, posts, copies, companies, tracked, seen_keys):
    read = [c for c in copies if last_day < c["seen_day"] <= day < c["gone_day"]
            and (c["tier"] == "A" or day % TIER_EVERY[c["tier"]] == 0)]
    by_role = defaultdict(list)
    for c in read:
        p = posts[c["id"]]
        by_role[(p["company"], norm_title(p["title"]))].append(c)
    out = {k: [] for k in ("main", "reference", "seen", "dropped", "unverified", "closed")}
    in_titles = already = 0
    for key, cs in by_role.items():
        p = dict(posts[max(cs, key=lambda c: int(c["id"]))["id"]])
        p["sources"] = sorted({c["source"] for c in cs})
        scope = title_scope(p["title"], P)
        if scope == "out":
            continue
        if key in seen_keys:  # a later copy of a role an earlier run already handled
            already += 1
            continue
        seen_keys.add(key)
        in_titles += 1
        own = companies[p["company"]]["list"]
        if own == "works" and not is_open(p, day):
            out["closed"].append(dict(p, why="closed on the company's list, still on a board"))
            continue
        reason = gate(p, P, scope)
        if reason:
            out["dropped"].append(dict(p, why=reason))
            continue
        rf, share, above = role_fit(p, P, scope)
        total, line = fit_line(p, P, rf, share)
        if above:
            line += "; title above the record, name the leadership gap"
        p.update(role_fit=rf, total=total, fit_line=line, first_seen=day, key=list(key), state="open")
        if rf < P["show_bar_role"]:
            out["seen"].append(dict(p, why=f"role {rf:g}, {'light on the duties you want' if share < 0.5 else 'tools and years'}"))
        elif own != "works":
            out["unverified"].append(dict(p, why="board only" if own == "none" else "company list unreadable"))
        elif total >= P["cv_bar_total"]:
            p["verdict"] = "Strong fit" if total >= 9 else "Worth applying"
            p["brief"] = brief(p, P)
            out["main"].append(p)
            tracked[p["id"]] = p
        else:
            p["verdict"] = "Below the 8 bar, listed for reference"
            out["reference"].append(p)
            tracked[p["id"]] = p
    closed_now = []
    for pid, t in tracked.items():
        if t["state"] == "open" and not is_open(posts[pid], day):
            t["state"], t["closed_seen"] = "closed", day
            closed_now.append(t)
    log = {
        "day": day, "copies_read": len(read), "unique_roles": len(by_role), "in_titles": in_titles, "already_seen": already,
        "new_main": [f"{r['company']}, {r['title']} (fit {r['total']:g})" for r in out["main"]],
        "reference": len(out["reference"]), "seen_not_a_fit": len(out["seen"]), "dropped": len(out["dropped"]),
        "could_not_verify": len(out["unverified"]), "closed_on_board": len(out["closed"]),
        "tracked_closed": [f"{t['company']}, {t['title']}" for t in closed_now],
        "cvs_drafted": sum(1 for r in out["main"] if r["total"] >= P["cv_bar_interviewing"]),
    }
    return out, log

# ---- the fortnight ----------------------------------------------------------------


def main():
    ap = argparse.ArgumentParser()
    ap.add_argument("profile")
    ap.add_argument("--data", default="data")
    ap.add_argument("--out", default="output")
    args = ap.parse_args()
    P = json.load(open(args.profile))
    posts = {p["id"]: p for p in json.load(open(os.path.join(args.data, "postings.json")))}
    copies = json.load(open(os.path.join(args.data, "board_copies.json")))
    companies = json.load(open(os.path.join(args.data, "companies.json")))

    tracked, run_log, all_out, seen_keys = {}, [], defaultdict(list), set()
    last_day, last_start = -2, None  # the scan ran before the fortnight; day 0 reads the last 2 days
    for day, hour, kind in sorted(SCHEDULE):
        start = day * 24 + hour
        if last_start is not None and start - last_start < 20:
            run_log.append({"day": day, "kind": kind, "skipped": f"last run started {start - last_start:.0f}h ago, under 20h"})
            continue
        out, log = run(day, last_day, P, posts, copies, companies, tracked, seen_keys)
        log["kind"] = kind
        run_log.append(log)
        for k, v in out.items():
            all_out[k] += v
        last_day, last_start = day, start

    shown = all_out["main"] + all_out["reference"]
    assert all(companies[r["company"]]["list"] == "works" for r in shown), "an unverified role was shown"
    assert all(r["role_fit"] >= P["show_bar_role"] for r in shown), "a weak role was shown"
    assert all(r["total"] >= P["cv_bar_total"] for r in all_out["main"]), "a role under the bar got a brief"
    assert not any(r["company"] in P["rejected_before"] for r in shown), "a done story came back"
    ids = [r["id"] for r in shown]
    assert len(ids) == len(set(ids)), "a role was reported twice"

    os.makedirs(os.path.join(args.out, "jds"), exist_ok=True)
    keep = ["id", "company", "title", "location", "workplace", "url", "sources", "role_fit", "total", "fit_line",
            "verdict", "brief", "why", "first_seen", "state", "closed_seen", "employees", "pay_k_eur", "duties",
            "tools", "years_required", "languages_required"]
    slim = lambda rs: [{k: r[k] for k in keep if k in r} for r in rs]
    board = {"profile": P["name"], "days": DAYS, "run_log": run_log,
             "main": slim(all_out["main"]), "reference": slim(all_out["reference"]), "seen": slim(all_out["seen"]),
             "dropped": slim(all_out["dropped"]), "could_not_verify": slim(all_out["unverified"]),
             "closed_on_board": slim(all_out["closed"])}
    with open(os.path.join(args.out, "board.json"), "w") as f:
        json.dump(board, f, indent=1)
    runs = [r for r in run_log if "skipped" not in r]
    summary = {
        "profile": P["name"], "runs": len(runs), "skipped": len(run_log) - len(runs),
        "copies_read": sum(r["copies_read"] for r in runs), "unique_roles": sum(r["unique_roles"] for r in runs),
        "in_titles": sum(r["in_titles"] for r in runs), "already_seen": sum(r["already_seen"] for r in runs), "main_8_plus": len(all_out["main"]),
        "reference": len(all_out["reference"]), "seen_not_a_fit": len(all_out["seen"]), "dropped": len(all_out["dropped"]),
        "could_not_verify": len(all_out["unverified"]), "closed_on_board": len(all_out["closed"]),
        "tracked_closed_later": sum(len(r["tracked_closed"]) for r in runs), "cvs_drafted": sum(r["cvs_drafted"] for r in runs),
        "drop_reasons": dict(Counter(r["why"] for r in all_out["dropped"]).most_common()),
        "main": [f"{r['company']}, {r['title']}: {r['fit_line']}" for r in all_out["main"]],
    }
    with open(os.path.join(args.out, "summary.json"), "w") as f:
        json.dump(summary, f, indent=2)
    for r in all_out["main"]:
        jd = [r["title"], f"{r['company']}, {r['location']} ({r['workplace']})", "", "What you will do:"]
        jd += [f"- {d}" for d in r["duties"]] + ["", "Tools: " + ", ".join(r["tools"]), f"Experience: {r['years_required']}+ years"]
        with open(os.path.join(args.out, "jds", f"{r['id']}.txt"), "w") as f:
            f.write("\n".join(jd) + "\n")
    print(json.dumps(summary, indent=2))


if __name__ == "__main__":
    main()