How the Drafter Applies Part A Edits in AI Job Search: Complete Technical Guide
The drafter applies Part A edits by iterating over a JSON array of structured string replacements and invoking the internal Edit tool for each object without rereading the draft files, ensuring deterministic updates based on reviewer feedback.
In the MadsLorentzen/ai-job-search repository, the /apply command implements a rigorous two-stage pipeline for job application generation. After the reviewer critiques initial drafts produced by the drafter, feedback flows back as Part A edits—machine-readable instructions defined in .claude/commands/apply.md—enabling precise, automated modifications to LaTeX source files.
Understanding the Part A Edit Schema
Part A edits follow a strict JSON structure that eliminates ambiguity. Each edit object must contain four mandatory fields that map directly to the Edit tool API.
The Four Required Fields
Every element in the Part A edits array specifies:
file: Relative path to the target document (e.g.,cv/main_acme_corp_data_scientist.tex)old_string: The exact text segment to locate, quoted verbatim from the draftnew_string: The replacement text that fulfills the reviewer’s directivereason: Categorical justification such as keyword match, company angle, reframing, style, or grounding
This schema, documented at lines 166‑175 of .claude/commands/apply.md, guarantees that the drafter can execute changes deterministically without semantic interpretation.
How the Edit Tool Processes Changes
The drafter feeds each JSON object directly into the Edit tool rather than parsing the document programmatically. As specified at lines 198‑199 of the same command file, the drafter does not reread the draft files before application; it relies on the old_string values supplied in the array, which were extracted from the draft content provided earlier in the session.
This design choice prevents drift between the reviewer’s context and the drafter’s execution state, ensuring that byte-level replacements match the expected source exactly.
Source Code Implementation Details
The application logic resides primarily in .claude/commands/apply.md, where the pipeline distinguishes between two feedback types:
- Part A (Structured Edits): Direct string replacements via JSON
- Part B (Narrative Suggestions): Prose guidance for complex revisions
For Part A, the drafter iterates through the edits array and validates each entry against fabrication rules. If a reason implies inventing unverified information—such as fabricating metrics not found in the candidate profile—the drafter skips that edit to maintain factual integrity.
Validation Against Candidate Profile
When the reviewer flags a grounding edit, the drafter validates the proposed new_string against .claude/skills/job-application-assistant/01-candidate-profile.md. This file serves as the source of truth for candidate data, ensuring that percentage figures, project names, and skill proficiencies remain accurate and traceable to the original profile.
Code Example: Applying Part A Edits
Below is a representative JSON payload returned by the reviewer:
[
{
"file": "cv/main_acme_corp_data_scientist.tex",
"old_string": "Increased revenue by 5 % in Q1 2023.",
"new_string": "Increased revenue by 12 % in Q1 2023.",
"reason": "grounding"
},
{
"file": "cover_letters/cover_acme_corp_data_scientist.tex",
"old_string": "I am excited about the opportunity at Acme Corp.",
"new_string": "I am excited about the Data‑Science role at Acme Corp, especially its focus on AI‑driven product analytics.",
"reason": "company angle"
}
]
The drafter processes these instructions using a loop that invokes the Edit tool:
for edit in edits:
Edit(
file=edit["file"],
old_string=edit["old_string"],
new_string=edit["new_string"]
)
File Targets and Template Inheritance
Part A edits operate on copies derived from master templates, not the originals. The baseline sources are:
cv/main_example.tex— Master CV templatecover_letters/cover_example.tex— Master cover letter template
When the drafter initializes a new application, it clones these templates into job-specific paths (e.g., cv/main_acme_corp_data_scientist.tex). The Part A edits reference these derivative files, leaving the master templates pristine for future reuse.
Summary
- Part A edits utilize a JSON array with mandatory
file,old_string,new_string, andreasonfields defined in.claude/commands/apply.md. - The drafter invokes the Edit tool iteratively without reloading source files, optimizing for speed and consistency.
- Edits target job-specific copies derived from
cv/main_example.texandcover_letters/cover_example.tex. - Fabrication-prone suggestions are automatically skipped to preserve factual accuracy against
01-candidate-profile.md.
Frequently Asked Questions
What is the JSON schema for Part A edits in AI Job Search?
Each Part A edit must include four fields: file (target path), old_string (exact text to replace), new_string (replacement content), and reason (categorical justification such as grounding or company angle). This schema enables deterministic string replacement without file re-parsing.
Why does the drafter skip certain Part A edits?
The drafter skips edits whose reason or content would require fabricating information not present in the candidate profile. For example, if an edit suggests adding unverified revenue figures without grounding in 01-candidate-profile.md, the drafter omits it to prevent factual errors.
Which source files provide the baseline for Part A edits?
The drafter generates job-specific documents from master templates located at cv/main_example.tex and cover_letters/cover_example.tex. Part A edits reference these derived copies rather than the master files, ensuring the original templates remain unchanged for subsequent applications.
How does the drafter handle file paths in Part A edits?
The file field in each Part A edit specifies the relative path to the target document, such as cv/main_acme_corp_data_scientist.tex. The drafter resolves these paths against the working directory and passes them directly to the Edit tool, which performs in-place string substitution without loading the file into a buffer for re-reading.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →