htmlp
Statically enforceable token limits for context files
Agents write their own skills. Context fills with slop. Prompts grow unbounded. HTMLP enforces a token budget, pushing agents to decide what belongs, what to cut, and when a larger budget needs justification.
Write a prompt file
Use the .htmlp extension. Set max-tokens and a brief reason. Name elements whatever fits and write Markdown inside them.
<htmlp max-tokens="2k" reason="Loaded on every request.">
<workflow id="routine" max-tokens="500" reason="Keep routine steps short.">
Read the code. Make one change. Run its tests.
</workflow>
</htmlp>
Sign and check
cargo install --git https://github.com/alexmckenley/htmlp --tag v0.3.0-alpha.1 --features cli
htmlp sign ./prompts
htmlp check ./prompts
2k means 2,000 tokens. The checker reports invalid markup, missing reasons, changed budget signatures, and exceeded limits. Each file is independent; no repository configuration is needed.
Signing records each limit and its reason in a short sig. Re-sign intentional budget changes; content edits need only a check.
Build the same document in Rust
Markup and Rust share one primitive: an element with a name, an optional id, and budgets. template interpolates {{name}} exactly as a file does, so an in-memory document produces the same nodes as its parsed equivalent.
use htmlp::{Document, Element};
let workflow = Element::new("workflow")
.id("routine")
.max_tokens(500, "Keep routine steps short.")
.template("Read {{path}}. Make one change.")
.expect("valid template");
let mut document = Document::new(2_000, "Loaded on every request.", vec![workflow.into()]);
document.sign();
HTMLP validates structure and token budgets. Roles, message kinds, and usage accounting stay in your own types, where you can change them without a format release.