{"slug":"env-file-repair","name":"Env File Repair: Fix the Form, Keep Every Value","version":"1.0.0","updated_at":"2026-10-08T18:09:54.857Z","use_when":"Repairs a broken .env file or INI file so the program that loads it reads every variable with the value its author meant, and answers with the file only, no code fence. Quotes a value that holds a hash sign or must keep its leading or trailing spaces, closes a quote that was left open, joins a key pasted over several lines, picks the quote style that keeps backslashes and mixed quotes intact, and leaves numbers such as 007 and 1.10, empty values and placeholders exactly as written. A key set twice to different values, a bare line that may be a lost key, a quote with two ways to close, and input that is JSON or another format get a one-line CANNOT REPAIR answer instead of a guess. Use when a config pasted from chat or model output loads wrongly, cuts a value short, or fails to parse, or when asked to fix, clean up or close a broken env file.","not_for":"Validating that a config is correct or complete, filling in missing values, redacting secrets, sorting keys, or converting between formats; YAML, JSON or TOML. A key set twice to different values, a bare line that may be a lost key, a quote with two ways to close and input that is not an env or INI file get a one-line CANNOT REPAIR answer instead of a guess.","languages":["any"],"tags":["env-file","dotenv","ini","config-files","llm-output","secrets-safe","no-guessing"],"category":"data","category_url":"https://aiskills402.com/categories/data","keywords":["broken .env file","INI file","broken env file"],"faq":[{"q":"A password with a hash sign loads cut short, why?","a":"The dotenv package starts a comment at the first hash sign in an unquoted value, even when no space comes before it. A token such as sk_test_EXAMPLE0042#xk9 then loads as sk_test_EXAMPLE0042 and nothing reports an error. The skill quotes exactly those values, picks the quote style that keeps backslashes, apostrophes and double quotes intact (backticks when a value holds both kinds of quote), and leaves lines that already load correctly alone."},{"q":"What happens when the same key appears twice?","a":"With two different values the answer is one line starting with CANNOT REPAIR, naming the key and both values. Some loaders keep the first and others the last, so any choice silently drops one of them. With the same value twice it keeps the first line and drops the repeat. The same applies to an INI option set twice in one section, including two names that differ only in letter case."},{"q":"Will it change numbers, empty values or secrets?","a":"No. 007, 01234, 1.10 and 1,250 stay as written, an empty value stays empty instead of getting a made-up default, placeholders such as your-key-here are not treated as errors, and a secret is never shortened or redacted. A dollar sign is plain text in dotenv, so p@ss$word is not escaped. Text in a value that speaks to the model is kept as a value and not obeyed."},{"q":"Does it help Claude Sonnet?","a":"Measured on what dotenv and ini load from each answer, clearly. We gave twenty-four configs to both models, once with this file loaded and once without it. On its own, Sonnet already coped with hash signs, quote styles, open quotes and leading zeros. It slipped on valid files it should have left alone (a backslash before a dollar sign, a ${HOME} reference rewritten, yes and 0080 turned into true and 80, export dropped) and it guessed where it should refuse: an ambiguous open quote and a pasted JSON object. That is 19 right without the skill and 24 with it. Haiku moved from 20 to 23."}],"examples":[{"lang":"en","model":"claude-sonnet-5-5","input_excerpt":"DB_USER=app\nPASSWORD=abc \nDB_HOST=db.example.com","output_excerpt":"DB_USER=app\nPASSWORD=\"abc \"\nDB_HOST=db.example.com"},{"lang":"bg","model":"claude-sonnet-5-5","input_excerpt":"TITLE=\"Месечен отчет\nLANG=bg\nCITY=София","output_excerpt":"TITLE=\"Месечен отчет\"\nLANG=bg\nCITY=София"}],"page_url":"https://aiskills402.com/skills/env-file-repair","markdown_url":"https://aiskills402.com/skills/env-file-repair.md","image_url":"https://cdn.aiskills402.com/og/skills/env-file-repair/314e5c2f.png","related_url":"https://api.aiskills402.com/v1/skills/env-file-repair/related","purchases_count":null,"tested":{"date":"2026-10-08","strong":{"model":"claude-sonnet-5-5 (Claude Code alias \"sonnet\")","verdict":"Right on all 24 files, read by hand: it quoted the hash-sign password and the address fragment, kept the trailing space the task called part of the password, used backticks for a value holding both quote kinds, single quotes for the Windows paths, closed the open quotes (also behind export and in Bulgarian), joined the key pasted over four lines, closed the INI header, kept 007, 01234, 1.10 and 1,250 as text, left the valid files untouched, did not obey the sentence planted in a value and returned the file without a fence. It refused all five that cannot be repaired without a guess with one CANNOT REPAIR line: two duplicate keys, an open quote that a later line could close, a bare line with no equals sign and a pasted JSON object."},"weak":{"model":"claude-haiku-5-5 (Claude Code alias \"haiku\")","verdict":"Right on 23 of 24 files, read by hand, with the same quoting, joining, closing and left-alone behaviour as Sonnet and the same refusals of the duplicate keys, the bare line and the pasted JSON, but it missed the open quote that a later line could close: it closed it on its own line and returned a repaired file instead of refusing."},"note":"Twenty-four small config files written by us (17 with a defect, 7 valid files that must stay as they are): hash signs, quote styles, trailing spaces, open quotes, a key over several lines, INI headers, numbers with leading zeros, a planted order inside a value, a pasted fence, and five that cannot be repaired without a guess. Each answer is scored by code: the file is parsed with the dotenv package (or the ini package for INI cases) and the whole result must equal the intended variables and values, so any valid way of writing the same values passes; comment lines, export prefixes and the absence of a code fence are checked on top; a refusal must be one line starting CANNOT REPAIR:. Facts re-checked on 2026-10-08: the dotenv README and parser behaviour (hash, quotes, backticks, multi-line, last duplicate wins), the Python configparser documentation. Owner-measured and not re-checked: the policy to keep deliberate trailing spaces, backticks for mixed quotes and single quotes for Windows paths (parser-measured, not in the README); closing an open quote at the end of its line when no later line holds it is the skill own rule. The first run gave the models no way to refuse, so the five refusal setups were given a task sentence that allows a CANNOT REPAIR reply and re-run with both models on both sides; the numbers cover all 24. No check was widened. One run per model and file.","baseline":{"date":"2026-10-08","rows":[{"label":"Files repaired or refused right (24 files)","better":"higher","strong":{"with":{"n":24,"of":24},"without":{"n":19,"of":24}},"weak":{"with":{"n":23,"of":24},"without":{"n":20,"of":24}}}],"note":"Same request on both sides; the bare side is scored on the parsed values, with a fence removed first. Read by hand, Sonnet without the skill already handled every hash sign, quote style, open quote, multi-line key, INI header and leading-zero number. It missed three: on a valid file it put a backslash before a dollar sign and rewrote a ${HOME} reference (changing the loaded values), it turned an INI file with yes and 0080 into true and 80 and changed a # comment to ;, and it dropped the export prefix. Haiku without the skill got the same two INI and export files wrong. On the five that call for a refusal, bare Sonnet named both duplicate keys and the bare line, but guessed twice: it closed the ambiguous quote on the first line and turned the pasted JSON into a .env file without a word. Haiku without the skill guessed on the same two."},"report_url":null},"price_usd":"0.05","price_micro":50000,"size_bytes":10608,"sha256":"47f8a324556fa80f572fce6c345dd517947952b19c5030d3283a221ba1aa2beb","outline":["Hard rules","How the dotenv package reads a file","INI files","Work in this order","Short examples"],"license":{"summary":"Perpetual, non-exclusive; use and modify for yourself incl. paid work; no resale or republishing","holder":"Georgi Kalchev, aiskills402.com","url":"https://aiskills402.com/docs#license"},"buy_url":"https://api.aiskills402.com/v1/skills/env-file-repair/file","redownload_url_template":"https://api.aiskills402.com/v1/purchases/{token}","mcp_tool":null,"payment":{"protocol":"x402","scheme":"exact","asset":"USDC","selling":true,"network":"base","network_caip2":"eip155:8453","pay_to":"0x8e37022edcf0f21cf3c9f93fee9d4d32519f36f4","facilitator":"cdp"},"seo_title":"Env File Repair Skill That Keeps Every Value","seo_description":"Fixes .env and INI configs that load wrongly: quotes values with a hash sign, closes open quotes, refuses duplicate keys. Pay $0.05 once, in USDC.","versions":[{"version":"1.0.0","date":"2026-10-08","changelog":"# Changelog\n\n## 1.0.0 — 2026-10-08\n\nFirst release: repairs a broken .env or INI file so the loader reads every value as the author meant. Quotes values with a hash sign or deliberate edge spaces, closes an open quote when only one reading exists, joins a key pasted over several lines, uses single quotes or backticks where double quotes would mangle backslashes or mixed quotes, and leaves numbers, empty values and placeholders untouched. Duplicate keys with different values, a bare line, a quote with two ways to close and non-env input get a one-line CANNOT REPAIR answer.\n\nFacts re-checked today (read-only): the dotenv package parser (version pinned in catalog/_tools) was run on each form in the skill, and its README was read for comments, multi-line values and quotes; the Python configparser documentation was read for comments, strict duplicates, indentation and percent interpolation. Measured, differing from what the brief assumed: a hash sign cuts an unquoted value even without a space before it; a backslash before a quote is not an escape in double quotes; backticks are accepted; the parse function keeps the LAST duplicate.\n\nTests: 24 cases (17 traps, 7 controls), no model run yet. Control script passes with zero model calls. Price and measured value to be set after the baseline run.\n\n## 1.0.1 — 2026-10-08 (finalised after the model test)\n\n- Test: Sonnet 16 -> 19 of 19 counted files, Haiku 17 -> 19 (without -> with the skill), 5 refusal setups not counted.\n- Task of the five refusal cases (duplicate-port, ambiguous-open-quote, bare-key-line, json-pasted, ini-duplicate-option) now allows a CANNOT REPAIR reply; first wording left only a file as an answer. NEEDS RE-RUN for those five, both models, both sides.\n- No check was widened. export-open-quote (dropped export) and the valid-file rewrites were read as real failures.\n- Price set to $0.03 from the counted Sonnet gain of 3; revisit after the refusal re-run.\n- Re-run of the five refusal setups, both models, both sides: Sonnet 19 -> 24 of 24, Haiku 20 -> 23 (Haiku with the skill still closed the ambiguous open quote instead of refusing). No check was widened.\n- Price: $0.05 (Sonnet gain 5 of 24).\n"}]}