hermes

Write a streaming file parser

Writes a streaming parser and validator for CSV, log, fixed-width or custom text files that reports malformed records with line numbers instead of crashing. Use for messy input files.

context

Real input files are never as clean as the sample suggests. Quoted CSV fields hold commas and newlines, so a line is not a record. Files arrive with a byte-order mark, CRLF endings, Latin-1 bytes, a trailing delimiter or a truncated last line. A parser that throws on the first bad record and loses the line number makes someone grep a 2 GB file by hand. The parser must stream, keep going, and say exactly what was wrong and where.

task

Write a parser and validator in (if empty, pick one suited to the job and say why) for files like this sample:

Known format notes:

  1. Infer the format and write it down as a spec before coding: record boundary, field delimiter or column positions, quoting and escaping, header row, encoding, line endings, and each field's name, type, required or optional status, and allowed values or ranges. Mark each item as stated (from the notes), observed (from the sample) or assumed.
  2. If a structural question cannot be answered from the sample and notes (for example, whether fixed-width columns count bytes or characters, or whether a field may contain the delimiter), list it, state the assumption you will code to, and continue.
  3. Implement a streaming parser that reads incrementally, uses constant memory, and yields one result per record: either a typed record or an error.
  • For CSV-like formats, use the language's real CSV library rather than splitting on commas, and track the physical line where each record starts.
  • For log lines, use one anchored pattern per line type, and join continuation lines such as stack traces onto their record.
  • For fixed-width formats, slice by the documented unit and trim as the spec says.
  1. Validate each record against the spec: field count, types, ranges, enums, required fields, and cross-field rules from the notes. Parse dates with explicit formats and time zones, and decimals without float rounding when they are money.
  2. Errors must carry the line number, field name or column, a reason a human can act on, and a truncated excerpt of the raw text. Keep going after errors. Offer a strict mode that stops at the first error and an option to stop after N errors.
  3. Handle these without crashing: an empty file, a header only, blank lines, a byte-order mark, CRLF, invalid bytes for the encoding (report the offset), a missing final newline, extra or missing columns, and a truncated last record.
  4. Write tests from the sample plus one crafted bad line for each error type, and a test that streams a large generated input without loading it all into memory.
constraints
  • Never silently coerce or drop a bad value. It is either valid or reported.
  • Keep the parsing core free of I/O so it can be tested with strings.
  • Do not echo whole records containing personal data in errors; truncate excerpts.
  • Separate what you verified from what you inferred. Mark inferences as such.
  • When you do not know, say "I don't know" once and state what would settle it.
output format

Format spec

| Field | Position or column | Type | Required | Rule | Source (stated / observed / assumed) | Then record boundary, encoding and quoting in a few lines.

Questions and assumptions

Numbered, or "None".

Code

Complete code in one or more code blocks.

Tests

Code, then one line per test explaining what it proves.

Sample run

What the parser yields for the given sample: the record count, then each error with its line number and reason.

1 required value still a placeholder; the assistant will ask for it.

details

kind
Prompt: a task you run by name to get one finished thing back
domain
Software engineering
category
Implementation
level
Intermediate
made for
Software engineer, Data engineer, Backend engineer
risk
read-only
version
v1.0.0 · incubating
reviewed
2026-10-02
works in
Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Antigravity, OpenCode, Windsurf, Zed, Continue, AGENTS.md, ChatGPT, claude.ai

Edit on GitHubReport a problem

use in

Hodios CLI
npx @hermes-hq/hodios install write-file-parser --target claude-code
Agent Skills
npx skills add hermes-hq/hodios-dist --skill write-file-parser -a claude-code
Add the Hodios marketplace (once)
claude plugin marketplace add hermes-hq/hodios-dist
Install the software-engineering plugin
claude plugin install hodios-software-engineering@hodios

The plugin brings every entry in this domain at once.

more in implementation

All of Implementation
PromptImplementation

Put a change behind a feature flag

Wraps new behaviour behind a feature flag with a safe default, a kill switch, tests for both paths and a cleanup ticket. Use when shipping a risky change incrementally.

add-feature-flag
PromptImplementation

Add rate limiting to an API

Adds rate limiting to API endpoints with a fitting algorithm, keys, per-tier limits, standard headers, 429 responses and tests. Use when protecting endpoints from abuse or overload.

add-rate-limiting
PersonaImplementation

Backend engineer

Acts as a backend engineer focused on correct data handling, clear API contracts, explicit failure modes and services that are easy to operate. Use as a builder or reviewer persona for server code.

backend-engineer
PromptImplementation

Build a REST endpoint end to end

Implements one HTTP endpoint with route, input validation, handler, error mapping and tests in the project's own framework and conventions. Use when adding an API route.

build-rest-endpoint
PromptImplementation

Build a reusable UI component

Builds a typed, accessible UI component from a description or screenshot, with loading, empty and error states and a usage example. Use when adding a component to a frontend.

build-ui-component
PromptImplementation

Build a webhook handler

Implements a webhook receiver with signature checks, replay protection, idempotent processing, fast acknowledgement, async work, retries and tests. Use when integrating Stripe, GitHub or similar.

build-webhook-handler