mirror of
https://github.com/MadsLorentzen/ai-job-search.git
synced 2026-09-17 08:36:25 +00:00
feat(apply): add mandatory PDF compile-and-inspect step and relevance-weighted cutting
Adds a new Step 5 to the /apply workflow that compiles the CV (lualatex)
and cover letter (xelatex) and visually inspects the resulting PDFs before
presenting them to the user. This catches page-break failures that .tex
review cannot detect: orphaned cventry titles, cover letters spilling to
a second page, and bullet fonts not matching body text.
Also introduces relevance-weighted cutting as the rule for shrinking an
overflowing CV: score each candidate line by (a) relevance to the posting,
(b) uniqueness in the document, and (c) load-bearing role in the cover
letter, then cut the lowest-total-score line first, regardless of section.
This replaces the old static "cut oldest section first" heuristic, which
was wrong whenever a relevant older-role bullet competed with an
irrelevant recent-role bullet.
Bundled with the earlier pending token-efficiency improvements to the
/apply workflow (inline draft passing to the reviewer, scoped reviewer
file reads, single end-of-workflow verification pass).
Changes:
- .claude/commands/apply.md: new Step 5 (Compile & Inspect PDFs), renumber
old Step 5 to Step 6, update token-efficiency rules at top to reference
Step 6 for the verification checklist
- .claude/skills/job-application-assistant/05-cv-templates.md: switch
recommended compile engine from pdflatex to lualatex (pdflatex fails on
modern MiKTeX with fontawesome5 font-expansion errors), add
"Compile-and-Inspect Loop" section with needspace/enlargethispage
patterns, add "Relevance-weighted cutting" section
- .claude/skills/job-application-assistant/06-cover-letter-templates.md:
add compile command, add "Compile-and-Inspect Loop", document the
"\lettercontent{} + itemize" pitfall and the required font-matching
Raleway-Medium wrapper fix
- CLAUDE.md: add "Compiled PDF verification (MANDATORY)" checklist items
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.7
parent
c66d599d75
commit
32e63e5143
+106
-58
@@ -4,6 +4,12 @@ You are orchestrating a two-agent job application workflow. The job posting is p
|
||||
|
||||
Follow these steps **exactly in order**. Do not skip steps.
|
||||
|
||||
**Token-efficiency rules for this workflow:**
|
||||
- Never re-Read a file whose contents are already in your context from an earlier step. If you read it in Step 1, it is still available in Step 2.
|
||||
- When dispatching the reviewer agent, pass draft content **inline in the agent prompt** rather than asking the agent to Read files you already have in memory.
|
||||
- Run the full verification checklist exactly once, at the end (Step 6). The reviewer focuses on content critique, not verification.
|
||||
- Step 5 (compile and inspect PDFs) is mandatory and non-skippable — LaTeX page-break decisions are unpredictable, and `.tex` files that look fine often produce broken PDFs (orphaned entry titles, cover letters spilling to page 2, bullet fonts mismatching).
|
||||
|
||||
---
|
||||
|
||||
## Step 0: Parse Input
|
||||
@@ -46,13 +52,14 @@ After presenting the evaluation, ask the user:
|
||||
|
||||
## Step 2: DRAFTER - Draft CV + Cover Letter
|
||||
|
||||
Read the following reference files:
|
||||
- `.claude/skills/job-application-assistant/01-candidate-profile.md`
|
||||
You already have `01-candidate-profile.md` and `04-job-evaluation.md` in context from Step 1. **Do not re-read them.**
|
||||
|
||||
Read only the reference files you do not yet have:
|
||||
- `.claude/skills/job-application-assistant/03-writing-style.md`
|
||||
- `.claude/skills/job-application-assistant/05-cv-templates.md`
|
||||
- `.claude/skills/job-application-assistant/06-cover-letter-templates.md`
|
||||
|
||||
Also read the most recent existing CV and cover letter files for structural reference:
|
||||
Also read the most recent existing CV and cover letter files for concrete structural reference (one of each is enough):
|
||||
- Read any existing `cv/main_*.tex` file as a LaTeX template reference
|
||||
- Read any existing `cover_letters/cover_*.tex` or `cover_letters/Cover_*.tex` file as a template reference
|
||||
|
||||
@@ -72,13 +79,15 @@ Also read the most recent existing CV and cover letter files for structural refe
|
||||
- Keep to approximately one page
|
||||
- Any mention of agentic coding or AI tooling must reference **Claude Code** by name
|
||||
|
||||
Write both files to disk.
|
||||
Write both files to disk. Keep the exact text of both drafts in working memory — you will pass them inline to the reviewer in Step 3 and revise them in Step 4 without re-reading.
|
||||
|
||||
---
|
||||
|
||||
## Step 3: REVIEWER - Research & Critique
|
||||
|
||||
Use the **Agent tool** to spawn a `general-purpose` reviewer agent with the following prompt:
|
||||
Use the **Agent tool** to spawn a `general-purpose` reviewer agent. The reviewer gets a fresh context, so pass the drafts **inline in the prompt** below (do not make the reviewer Read them). Scope the reviewer's file reads to content-critique essentials only — the reviewer does not need the LaTeX template files (`05`, `06`) or the behavioral profile (`02`) to critique content.
|
||||
|
||||
Replace `<COMPANY>`, `<ROLE>`, `<INSERT_JOB_POSTING_TEXT_HERE>`, `<INSERT_CV_DRAFT_HERE>`, and `<INSERT_COVER_LETTER_DRAFT_HERE>` with actual values before dispatching.
|
||||
|
||||
```
|
||||
You are a hiring manager proxy reviewing a job application. Your job is to make the application as targeted and compelling as possible.
|
||||
@@ -92,63 +101,58 @@ Use WebSearch and WebFetch to research:
|
||||
- Any recent projects, press releases, or strategic initiatives relevant to the role
|
||||
- Company culture and values
|
||||
|
||||
### 2. Read All Reference Materials
|
||||
Read these files to understand the candidate and quality standards:
|
||||
### 2. Read Reference Materials (content-critique only)
|
||||
Read these three files — and only these — to ground your critique:
|
||||
- `.claude/skills/job-application-assistant/01-candidate-profile.md`
|
||||
- `.claude/skills/job-application-assistant/02-behavioral-profile.md`
|
||||
- `.claude/skills/job-application-assistant/03-writing-style.md`
|
||||
- `.claude/skills/job-application-assistant/04-job-evaluation.md`
|
||||
- `.claude/skills/job-application-assistant/05-cv-templates.md`
|
||||
- `.claude/skills/job-application-assistant/06-cover-letter-templates.md`
|
||||
|
||||
### 3. Read the Drafts
|
||||
Read the drafted CV and cover letter:
|
||||
- `cv/main_<COMPANY>.tex`
|
||||
- `cover_letters/cover_<COMPANY>_<ROLE>.tex`
|
||||
Do NOT read `02-behavioral-profile.md`, `05-cv-templates.md`, or `06-cover-letter-templates.md` — those are structural/behavioral references the drafter already applied and are not needed for content critique.
|
||||
|
||||
### 4. Read the Job Posting
|
||||
### 3. Drafts to Review
|
||||
Both drafts are provided inline below. Do NOT use the Read tool on the draft files — use these exact texts.
|
||||
|
||||
<CV_DRAFT file="cv/main_<COMPANY>.tex">
|
||||
<INSERT_CV_DRAFT_HERE>
|
||||
</CV_DRAFT>
|
||||
|
||||
<COVER_LETTER_DRAFT file="cover_letters/cover_<COMPANY>_<ROLE>.tex">
|
||||
<INSERT_COVER_LETTER_DRAFT_HERE>
|
||||
</COVER_LETTER_DRAFT>
|
||||
|
||||
### 4. Job Posting
|
||||
<JOB_POSTING>
|
||||
<INSERT_JOB_POSTING_TEXT_HERE>
|
||||
</JOB_POSTING>
|
||||
|
||||
### 5. Produce Feedback
|
||||
Return a structured critique with **specific, actionable suggestions** in these categories:
|
||||
|
||||
**a) Missed keywords/requirements**
|
||||
- List any requirements or keywords from the posting that are not addressed in the CV or cover letter
|
||||
- For each, suggest where and how to add them (with specific text suggestions)
|
||||
Return your feedback in **two parts**:
|
||||
|
||||
**b) Company/department-specific angles**
|
||||
- Based on your research, suggest specific angles to add
|
||||
- Suggest how to connect experience to the company's strategic priorities
|
||||
**Part A — Structured edits (preferred format whenever possible):**
|
||||
A JSON array of concrete edits the drafter can apply directly without re-reading the files. Each edit is an object:
|
||||
```json
|
||||
{
|
||||
"file": "cv/main_<COMPANY>.tex" | "cover_letters/cover_<COMPANY>_<ROLE>.tex",
|
||||
"old_string": "<exact text currently in the draft>",
|
||||
"new_string": "<replacement text>",
|
||||
"reason": "<one-line rationale: keyword match / company angle / reframing / style>"
|
||||
}
|
||||
```
|
||||
Only use this format when you can quote the exact `old_string` from the drafts above. Make `old_string` unique — include enough surrounding context so it matches exactly once per file.
|
||||
|
||||
**c) Action-oriented reframing**
|
||||
- Identify passive or generic statements and suggest action-oriented rewrites
|
||||
|
||||
**d) Tone and style issues**
|
||||
- Check against the writing style guide (03-writing-style.md)
|
||||
- Flag any issues with tone, formality, or voice
|
||||
|
||||
**e) Verification checklist**
|
||||
Run this checklist and report pass/fail for each:
|
||||
- [ ] All claims match actual profile - no fabricated skills, experience, or achievements
|
||||
- [ ] Job titles, dates, company names, and locations are correct
|
||||
- [ ] Contact details are correct
|
||||
- [ ] Profile statement is tailored to the specific role
|
||||
- [ ] Key job requirements are addressed
|
||||
- [ ] No LaTeX syntax errors (balanced braces, correct commands)
|
||||
- [ ] No spelling or grammar errors
|
||||
- [ ] Agentic coding / AI tooling references mention Claude Code by name
|
||||
- [ ] Cover letter addressed correctly
|
||||
- [ ] Cover letter fits approximately one page
|
||||
- [ ] CV follows 2-page moderncv/banking format
|
||||
**Part B — Narrative suggestions (for judgment calls that are not mechanical edits):**
|
||||
Prose suggestions grouped by category:
|
||||
- **Missed keywords/requirements** — what to add and roughly where, if it cannot be expressed as a clean string replacement
|
||||
- **Company/department-specific angles** — connections between experience and the company's strategic priorities, based on your research
|
||||
- **Tone and style issues** — anything that conflicts with `03-writing-style.md`
|
||||
|
||||
**CRITICAL RULE:** All suggestions must be grounded in actual profile data. Do NOT suggest fabricating skills, experience, or achievements. If a requirement is a gap, say so honestly and suggest how to frame adjacent experience instead.
|
||||
|
||||
Return your full feedback as a single structured message.
|
||||
```
|
||||
Do **not** run a verification checklist — the drafter will do that in the final step. Focus on content critique.
|
||||
|
||||
**Important:** Before spawning the agent, replace `<COMPANY>`, `<ROLE>`, and `<INSERT_JOB_POSTING_TEXT_HERE>` with the actual values from Steps 0-2.
|
||||
Return Part A and Part B together as a single structured message.
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
@@ -156,25 +160,69 @@ Return your full feedback as a single structured message.
|
||||
|
||||
Once the reviewer agent returns its feedback:
|
||||
|
||||
1. Read the reviewer's suggestions carefully
|
||||
2. Read both draft files again
|
||||
3. Incorporate the suggestions that improve the application:
|
||||
- Add missed keywords where they fit naturally
|
||||
- Add company-specific angles from the reviewer's research
|
||||
- Reframe passive statements to be more action-oriented
|
||||
- Fix any tone/style issues
|
||||
- Fix any verification checklist failures
|
||||
4. Update both files **in place** (edit, don't recreate)
|
||||
5. Do NOT incorporate suggestions that would fabricate skills or experience
|
||||
1. **Apply Part A (structured edits) directly with the Edit tool.** Do NOT re-read the draft files — you already have them in context from Step 2, and the reviewer's `old_string` values were quoted from that same text. For each edit in the JSON array, call `Edit` with the given `file`, `old_string`, and `new_string`. Skip any whose rationale would require fabricating content.
|
||||
2. **Apply Part B (narrative suggestions)** using judgment — these are the changes that need interpretation (reframing paragraphs, adding company angles, adjusting opening). Use Edit for targeted changes; only re-read a file if an edit fails because the surrounding text has shifted.
|
||||
3. Do NOT incorporate any suggestion that would fabricate skills or experience.
|
||||
|
||||
After all edits are applied, the two files on disk are the final drafts.
|
||||
|
||||
---
|
||||
|
||||
## Step 5: Present Final Output
|
||||
## Step 5: DRAFTER - Compile & Inspect PDFs (MANDATORY)
|
||||
|
||||
After revision, present to the user:
|
||||
**Never skip this step.** The `.tex` files looking fine is not sufficient — LaTeX page-break decisions are unpredictable and commonly produce broken layouts (orphaned job titles separated from their bullets, cover letters spilling to 2 pages, bullet fonts not matching body text). Compile both documents and visually verify the PDFs before presenting.
|
||||
|
||||
### 5a. Compile
|
||||
|
||||
```bash
|
||||
cd cv && lualatex -interaction=nonstopmode main_<company>.tex
|
||||
cd ../cover_letters && xelatex -interaction=nonstopmode cover_<company>_<role>.tex
|
||||
```
|
||||
|
||||
- CV uses **lualatex** — pdflatex fails on modern MiKTeX with fontawesome5 font-expansion errors. lualatex handles the same sources cleanly.
|
||||
- Cover letter uses **xelatex** — cover.cls requires fontspec.
|
||||
|
||||
If either compile fails, fix the error and re-compile until clean.
|
||||
|
||||
### 5b. Inspect layout
|
||||
|
||||
Read both PDFs via the Read tool and verify:
|
||||
|
||||
**CV (`cv/main_<company>.pdf`):**
|
||||
- [ ] Exactly 2 pages (not 1, not 3)
|
||||
- [ ] No orphaned `\cventry` titles — a job/education title line must never sit alone at the bottom of page 1 with its bullets on page 2. This is the most common failure.
|
||||
- [ ] Section headings are not isolated at the top of page 2 with only 1-2 lines below
|
||||
- [ ] No awkward whitespace gaps
|
||||
|
||||
**Cover letter (`cover_letters/cover_<company>_<role>.pdf`):**
|
||||
- [ ] Exactly 1 page
|
||||
- [ ] Signature block visible, not cut off or pushed to a second page
|
||||
- [ ] Bullet list font matches surrounding body text (both should be Raleway-Medium)
|
||||
|
||||
### 5c. Iterate until clean
|
||||
|
||||
If the layout has problems, edit the `.tex` files and recompile. Common fixes (see `05-cv-templates.md` and `06-cover-letter-templates.md` for full details):
|
||||
|
||||
- **Orphaned CV entry title:** `\usepackage{needspace}` in preamble, then `\needspace{5\baselineskip}` immediately before the problematic `\cventry`
|
||||
- **CV spills to page 3 with only a trailing section:** `\enlargethispage{2-3\baselineskip}` before a late section
|
||||
- **Substantial content on page 3:** cut content using **relevance-weighted cutting** (see `05-cv-templates.md` → "Relevance-weighted cutting"). Score each candidate line by (a) relevance to THIS posting's keywords and responsibilities, (b) uniqueness (is it duplicated elsewhere?), (c) narrative load (does the cover letter depend on it?). Cut the lowest-total-score line first, regardless of section. Do NOT mechanically apply a static section-based priority order — an older-role bullet that hits posting keywords is worth more than a recent-role bullet that does not.
|
||||
- **Cover letter itemize breaks compile or uses wrong font:** close `\lettercontent{}` before the list, wrap the list in `{\raggedright\fontspec[Path = OpenFonts/fonts/raleway/]{Raleway-Medium}\fontsize{11pt}{13pt}\selectfont \begin{itemize}...\end{itemize}\par}`
|
||||
- **Cover letter spills to 2 pages:** trim using the same relevance-weighted logic. First cut: sentences that restate what a bullet already said. Second cut: a bullet that does not hit posting keywords. Last resort: a bullet that does hit posting keywords. Never reduce geometry or line spacing.
|
||||
|
||||
Do not proceed to Step 6 until both PDFs pass inspection.
|
||||
|
||||
### 5d. Clean up build artifacts
|
||||
|
||||
After the final clean compile, delete the `.aux`, `.log`, `.out` files (keep the `.tex` and `.pdf`).
|
||||
|
||||
---
|
||||
|
||||
## Step 6: Present Final Output
|
||||
|
||||
Run the full verification checklist from `CLAUDE.md` now — this is the **only** verification pass in the workflow. Re-read both files once here to verify final state on disk matches your mental model after the Step 4 and Step 5 edits.
|
||||
|
||||
### Verification Checklist
|
||||
Re-run the full verification checklist from CLAUDE.md and report pass/fail for each item.
|
||||
Report pass/fail for each item in the CLAUDE.md verification checklist (factual accuracy, targeting, consistency, quality).
|
||||
|
||||
### Key Tailoring Decisions
|
||||
Summarize 3-5 key decisions made to tailor the application:
|
||||
|
||||
Reference in New Issue
Block a user