pupila-filters
Skill36 starsChanged 7 months agoMITView on GitHub
How to tune job filter scoring, hard-drop rules, or debug why a specific job was kept/dropped via _signals. Use when adjusting weights in config/profile.json, adding a hard-exclude rule, tuning keyword lists, debugging fitScore, or interpreting the per-job _signals breakdown.
In this repository18 other files it gives its agents.
- AGENTS.mdAGENTS.md
- .agents/skills/composition-patterns/AGENTS.mdAGENTS.md
- .agents/skills/react-best-practices/AGENTS.mdAGENTS.md
- ui/AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- ui/CLAUDE.mdCLAUDE.md
- accessibilitySkill
- vercel-composition-patternsSkill
- frontend-designSkill
- nodejs-backend-patternsSkill
- nodejs-best-practicesSkill
- vercel-react-best-practicesSkill
- seoSkill
- typescript-advanced-typesSkill
- viteSkill
- vitestSkill
- pupila-ai-reviewSkill
- pupila-fetchersSkill
The file
We split this skill into the rules it gives an agent
5 rules. About 0 are common, 1 is distinctive, and 4 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 8
All filter logic lives in src/filters.ts.
- Distinctive: line 78
No other plumbing — just append.
- Very specific: line 83
Add the weight to config/profile.json#weights.
- Very specific: line 118
Every kept job carries a _signals object showing which scoring rules fired:
- Very specific: line 151
When tuning a regex or weight, update tests in the same commit.
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
All filter logic lives in src/filters.ts. Weights + keyword lists load from config/profile.json at runtime via loadProfile() (NOT a static import — the file is gitignored and auto-bootstrapped from config/profile.default.json on first run). Adjusting weights or keywords is a non-code edit to profile.json.
Decision tree: what kind of change are you making?
| Task | Edit | Skill section |
| Change a scoring weight (e.g. seniority +15 → +20) | config/profile.json#weights.<field> | "Tuning weights" below |
| Add/remove a keyword (e.g. another Rust framework) | config/profile.json#keywords.<list> | "Tuning keywords" below |
| Add a new hard-drop rule | src/filters.ts (HARD_RULES array) | "Adding a hard-drop rule" below |
| Add a new positive signal type | src/types.ts + config/profile.json#weights + src/filters.ts | "Adding a new positive signal" below |
| Diagnose why a job has fitScore=N | Inspect _signals on the job | "Debugging via _signals" below |
Order of operations (in applyFilters)
- Hard excludes — URL safety, junior/intern titles, location-incompatible (persona-neutral — see "Location & work type" below), non-engineering compounds, leadership, non-frontend eng (since user is a frontend engineer), non-tech roles.
- Body preparation —
preparedScoringBody()strips boilerplate (EEO, privacy, "About us") and truncates toscoringBodyMaxChars(default 1500). Keyword scoring runs against this — prevents footer text like "we use Anthropic Claude internally" from landing a +20 AI signal on a backend role. Hard-drops still see the full body. - Soft scoring — additive, capped at
maxScore(100):- Categories — each configured
CategoryDefwhose keywords match adds itsweightonce (binary); defaultweight0 = pure label. Replaces the old hardcoded web3/ai signals. A job is tagged with every match (Job.categories). - Stack (+10 React/Next/TS, +5 RN/Expo, +5 GraphQL/Tailwind/Vite) — tiered
- Seniority (+15 lead/staff/principal/head, +10 senior/sr) — binary
- Frontend title (+10) — binary
- Frontend body (+10) — tiered
- Location (+10 when the job matches an accepted region / is remote — driven by the
locationblock) — binary - Freshness (+10 within 7d, +5 within 14d) — binary
- Categories — each configured
- Negative —
outOfRegionPenalty(default -10) if the job is region-locked outside the candidate's accepted regions and they haven't opted into hard-excluding. Applied after capping. (Persona-neutral; replaced the old US-centric penalty.) - Drop — anything with
fitScore < minScoreToKeep(default 30). - Categories —
job.categories= ids of everyCategoryDefwhose keywords matched (multi-label, config order);[]when none (renders under synthetic "Other"). Defined inconfig/profile.json#categories, generated from the brief on Regenerate or edited on the Profile tab. Each entry:{ id, label, keywords, scope?, weight?, limit? }.
Tiered weighting
tieredWeight(count, baseWeight) scales by occurrence:
| Matches | Weight |
| 0 | 0 |
| 1 | floor(base * 0.5) |
| 2–3 | base |
| 4+ | floor(base * 1.5) |
Implemented with global-flag regexes (STACK_PRIMARY_G, STACK_RN_G, STACK_OTHER_G, BODY_FRONTEND_KW_G) + countMatches. Other signals stay binary.
See references/scoring-tiers.md for the full tier table and per-signal regex catalog.
Tuning weights
Edit config/profile.json#weights.<field>. Re-run pnpm run dev (or just pnpm run ui — it reads the same file). No code change needed.
Tuning keywords
Edit config/profile.json#keywords.<list>. compileKw() joins each list with | and wraps in \b...\b/i at runtime. Lists currently include:
seniorReq,engineeringKw(whitelists — kept jobs must match these)nonEngineering,nonFrontendEng,nonEngLeadership,nonEngCompound,nonEngRole,nonTechRole(blacklists — drop on title match)stackPrimary,stackRn,stackOther(scoring signals)profile.json#categories[]: user-defined taxonomy ({ id, label, keywords, scope?, weight?, limit? }). Each match tagsjob.categoriesand addsweightto the score. Replaced the old hardcodedweb3*/ai*keyword groups. Categorykeywordsare plain LITERAL terms, not regex (unlike every list above): they're matched whole-word + case-insensitive bycompileCategoryKeywords()insrc/filters.ts, which anchors with alphanumeric lookarounds instead of\b, so punctuation-edged terms work (c++,c#,.net) and a dot between words is optional (node.jsalso matchesnodejs). List both for other variants (agent/agents). Edit by hand, regenerate from the brief, or use the Profile-tab editor (ui/src/CategoryPreferences.tsx); validated bysanitizeCategories()(literal-only, no regex compile) insrc/lib/profile-generator.ts.profile.json#roles[]— target job titles ({ id, label, titleMatch, bodyMatch? }); driveroleTitle/roleBody+job.roleMatches+ the hard-drop rescue (seereferences/scoring-tiers.md)locationLock,onsiteOnly,worldwideRemote— persona-neutral geo extraction groups (no country names); the keep/drop decision compares them againstprofile.json#location(see "Location & work type" below)locationRemote— fallback remote signal only used when a profile has nolocationblock
Adding a hard-drop rule
HARD_RULES in src/filters.ts is a named-rule list. applyFilters runs Array.find over the rules, increments droppedHard, and tallies the rule name in droppedByRule. Breakdown surfaces in JOBS.md (e.g. (missing_senior_req=812, ...)).
HARD_RULES.push({
name: 'descriptive_rule_name',
test: (job, ctx) => /* return true to drop */,
});No other plumbing — just append.
Adding a new positive signal
- Append the field to
JobSignalsinsrc/types.ts. - Add the weight to
config/profile.json#weights. - Append one line to the
positivesobject literal inapplyFilters.
The sum is Object.values(positives).reduce(...) — auto-includes any new field. No need to update the sum site.
Location & work type (persona-neutral geo)
Geo handling is driven entirely by the location block in config/profile.json — no country is privileged (a US-based and an EU-based profile get opposite outcomes from the same code; see the symmetry test in tests/filters.test.ts). Editable on the Profile tab (ui/src/LocationPreferences.tsx) or derived from the brief during Regenerate.
"location": {
"basedIn": "Spain", // where the candidate lives (single)
"workTypes": ["remote", "hybrid"], // accepted arrangements: remote | hybrid | onsite
"acceptedRegions": ["europe", "emea", "eu", "spain"], // region terms they'll work in (lowercased)
"excludeOutsideAcceptedRegions": true // true = hard-drop out-of-region; false = soft-penalize
}How hard_location_incompatible decides (rescue-first):
- Work-type gate — if the candidate doesn't accept
onsite, the job isn't remote, and the text matchesonsiteOnly→ drop. - Region gate (only when
excludeOutsideAcceptedRegionsand a region preference exists):- Rescue first — if the posting names an accepted region /
basedIn/worldwideRemoteanywhere, keep it (a "Remote - US" label whose body welcomes Europe survives).regionAccepted()deliberately does NOT treat a bare "remote" as a region. - Else drop if the stated location names a specific non-accepted place (
locationFieldOutOfRegion()— strips generic-remote tokens; "Remote" alone → empty residual → kept; "Remote, US" → "us" → dropped) or the body declares a real lock (locationLock— work authorization / must-be-based-in / timezone-required).
- Rescue first — if the posting names an accepted region /
Key invariants:
workTypesis only lightly wired:onsitecontrols the drop gate,remotefeeds the+locationRemotebonus.hybridis currently inert (captured but unused).- Bare "Remote"/"Worldwide"/"Global"/"Distributed" are always kept — a job does NOT need a region word to survive. Only an explicit non-accepted location requirement drops it.
- Empty
acceptedRegions+ emptybasedIn→ region logic is inert (a fresh fork drops nothing on geography). locationLock/onsiteOnly/worldwideRemoteare neutral extraction groups; tune the candidate's preference in thelocationblock, not those lists.
UI/data plumbing: useLocation hook + api.location ↔ GET/PUT /api/profile-location (ui/plugins/profile.ts); sanitizeLocation() validates both LLM and UI input (src/lib/profile-generator.ts).
Debugging via _signals
Every kept job carries a _signals object showing which scoring rules fired:
"_signals": {
"categories": { "web3": 20, "ai": 20 }, // id → weight contributed; mirrors job.categories
"stackPrimary": 10, "stackRn": 0, "stackOther": 0,
"leadTitle": 0, "seniorTitle": 10,
"roleTitle": 10, "roleBody": 10, "locationRemote": 10,
"freshness7d": 10, "freshness14d": 0, "outOfRegionPenalty": 0,
"rawTotal": 100, "capped": false
}_signals.categorieskeys are exactlyjob.categories; a value of 0 = a matched pure-label category.rawTotalis the un-capped positive sum.capped: truemeans positives summed > 100 before clamping.outOfRegionPenaltyis applied after capping.
Inspecting in-place
pnpm run dev
jq '.[0]._signals' data/jobs.json # first job
jq '.[] | select(.id == "<sha1>") | ._signals' data/jobs.json # specific job
jq '.[] | select(._signals.rawTotal > 100) | {company,title}' data/jobs.json # cappedIn the UI
The Jobs-tab detail panel (click a row) renders the _signals breakdown alongside the AI take and meta. Tier-coloured cells: green ≥80, gold 50–79, muted <50.
Updating tests when tuning
When tuning a regex or weight, update tests in the same commit. The frozen fixture lives at tests/fixtures/test-profile.json — bake new expected scores into tests/filters.test.ts (40 cases). Don't loosen the assertion to make a failing test pass.
Related
src/filters.ts— all logic.tests/filters.test.ts— every hard-drop branch, scoring signal, tiered weighting, boilerplate stripping.config/profile.json(gitignored) /config/profile.default.json(committed baseline).pupila-ai-reviewskill — when filters and AI verdicts disagree, the brief is usually the lever.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

