GrepBoard/Manuals
605 manuals ·

Build an FAQ from an internal policy with clause citations

·Tested on Claude Sonnet 5.5 · 2026-10·Test scope ↓·7 steps

Turn a 12-article travel policy into a 10-question FAQ where each answer cites and quotes an article, then verify by script that every quote is in that article.

The travel policy changes on November 1 and the intranet board fills with questions. The first attempt: paste the policy and ask "Make an FAQ answering these 10 employee questions". The lodging cap came out right. A question the policy is silent on came out like this.

output
**9. Can I rent a car and claim the cost?**The policy doesn't list rental cars. Covered transport is rail (standard class), city bus and subway, and a personal car at 0.30 per km one way plus tolls and parking with receipts (Art. 4). A rental car would need prior approval from the head of finance (Art. 11).

The first two sentences read the policy. The last one takes Article 11 (exceptions) and attaches it to a question it was not written for, so an employee reads it as "renting is fine if finance agrees". Below, every answer carries an article and a quote, and a script checks that the quote is really in that article and that questions the policy is silent on are answered as silent.

[1] Put the policy and the questions in files. The policy is fictional, 12 articles. Questions 8, 9 and 10 are ones the policy says nothing about. You have to know that yourself to pass it to the script.

policy.en.txt (Articles 5, 8, 11 only; full text in run/policy.en.txt)
Article 5 (Lodging) (1) Lodging is reimbursed per night up to 140 in the capital region, 110 in other major cities and 85 elsewhere. (2) The traveler pays any amount above the limit. (3) No lodging is paid for a same-day trip.Article 8 (Receipts and settlement) (1) Within 5 business days after returning, the traveler files for settlement with receipts and card slips attached. (2) Lodging and transport are not paid without proof. (3) If a receipt is lost, a signed loss statement confirmed by the department head counts as proof.Article 11 (Exceptions) A payment that differs from this policy needs prior approval from the head of finance.
questions.en.txt
1. I am staying one night in a major city that is not the capital region. How much can I claim for the hotel?2. What happens if my hotel cost goes over the limit?3. Can I take first class on the train?4. How early do I have to submit the trip request?5. Can I claim lunch separately during a trip?6. I lost a receipt. What do I do?7. How long after I come back do I have to file for settlement?8. If I add a personal day to the end of a trip, is that extra night covered?9. Can I rent a car and claim the cost?10. Can I claim a roaming or phone data charge incurred on a trip?

[2] Build the prompt. The policy and the questions go on top inside <policy> and <questions>, the instructions below. Anthropic's long-context guidance puts long material above the question and has the model quote the relevant parts first. OpenAI's prompt guide says to mark where reference material begins and ends with tags. The quoting principle became the "Quote" column: the writer has to copy a sentence first, which makes an unsupported answer harder to write. The prompt also says what to write when the policy is silent (Not in the policy, none, -). Without that, it makes up an answer.

tail.en.txt
Using only the facts in <policy>, build an FAQ for the company intranet. Answer the 10 questions in <questions> in numerical order. Employees will spend money based on this FAQ, so not a single line that is absent from the policy may slip in. Rules:- The output is one table with the columns `| No. | Question | Answer | Clause | Quote |`.- Write each answer in at most two sentences, using only what the policy says. Do not add common sense or what other companies usually do.- Write the clause as `Article 5 (1)`. The quote is copied character for character from that article, without quotation marks. Copy only the shortest part that supports the answer.- For a question the policy does not answer, write only `Not in the policy` in the Answer column, `none` in Clause and `-` in Quote. Do not invent a department or a contact.- Write nothing outside the table.

[3] Join policy, questions and instructions and run.

console
$ (echo "<policy>"; cat policy.en.txt; echo "</policy>"; echo; echo "<questions>"; cat questions.en.txt; echo "</questions>"; cat tail.en.txt) > prompt.en.txt$ claude -p --model claude-sonnet-5-5 --max-turns 1 --tools "" --setting-sources "" --strict-mcp-config < prompt.en.txt > out.en.1.txt

Part of the first result (3 of 10 rows; the rest is cut):

output
| No. | Question | Answer | Clause | Quote ||---|---|---|---|---|| 1 | I am staying one night in a major city that is not the capital region. How much can I claim for the hotel? | Lodging in other major cities is reimbursed up to 110 per night. | Article 5 (1) | 110 in other major cities |…| 8 | If I add a personal day to the end of a trip, is that extra night covered? | Not in the policy | none | - || 9 | Can I rent a car and claim the cost? | Not in the policy | none | - |

Question 9, which got an Article 11 pointer in the one-line version, now ends as "Not in the policy".

[4] The checking script looks at every table row.

  • Is the quote in the policy character for character (whitespace collapsed to one space), and inside the article it cites?
  • Are the numbers in the answer in the quote? (Numbers in the question are allowed.)
  • Are the silent questions (8, 9, 10) answered Not in the policy?
  • Did a question the policy does answer slip into Not in the policy? (It also checks that each of the ten numbers appears once.)
check.py (excerpt)
...  (reading the table, the silent-question check: see run/check.py)for no, q, a, clause, quote in rows:  # covered questions    m = cite.search(clause)    if not m or int(m.group(1)) not in articles:        fail.append(f"Q{no}: clause {clause!r} is not an article of the policy")        continue    n = int(m.group(1))    qt = norm(quote).strip('"“”「」')    if len(qt) < 8:        fail.append(f"Q{no}: quote too short to prove anything")    elif qt not in articles[n]:        where = [k for k, v in articles.items() if qt in v]        fail.append(f"Q{no}: quote not found in article {n}" + (f" (it is in article {where})" if where else " (nowhere in the policy)"))    else:        cited += 1        pm = para_of.search(clause)        paras = split_para(articles[n])        if pm and paras:                                      # the clause names a paragraph: the quote must be in that one            k = int(pm.group(1))            if k > len(paras) or qt not in norm(paras[k - 1]):                fail.append(f"Q{no}: quote is not in paragraph {k} of article {n}")    numset = lambda t: set(v.replace(",", "") for v in re.findall(r"\d[\d,]*(?:\.\d+)?", t))    for x in numset(a) - numset(quote) - numset(q):        fail.append(f"Q{no}: number {x} in the answer is not in the quote" + ("" if x in policy_nums else " or anywhere in the policy"))    extra = numset(quote) - numset(a) - numset(q)    if extra:                                                 # not a failure: the quote holds figures the answer does not use        notes.append(f"Q{no}: quote also holds {sorted(extra)} - read the answer against the quote")print(f"rows: {len(rows)}, quotes verified: {cited}, 'not in policy' answers: {refused}")...

[5] Run it on both results.

console
$ python3 -I check.py en policy.en.txt out.en.1.txtrows: 10, quotes verified: 7, 'not in policy' answers: 3exit 0$ python3 -I check.py en policy.en.txt out.en.2.txtrows: 10, quotes verified: 7, 'not in policy' answers: 3exit 0

Both pass. Clauses are identical across the two runs; quotes differ in rows 1 and 6 and answers in rows 1, 3, 4, 6 and 7, in wording only. The Korean edition was run twice as well and passed twice, with identical clauses and quotes and a different answer sentence only in row 1. An earlier prompt without the line "Copy only the shortest part that supports the answer" also passed in all four runs (two English, two Korean), but its English quotes were whole sentences holding three numbers (140, 110, 85), so answer 1 changed to "85" still passed. That hole is why the line was added; the results above are from the re-run. It narrows the hole but does not close it: in the second run the quote for answer 1 still holds both 140 and 110, so changing that answer to "140" would still pass the number check. The script now prints a NOTE for such rows (NOTE Q1: quote also holds ['140'] - read the answer against the quote) so a person looks at them. The one-line result is not a table, so the script cannot read it. Reading it by hand, answers 8, 9 and 10 all attach the Article 11 prior-approval procedure to things the policy never mentions, and answer 3 (first class on the train) adds a sentence that the extra cost is not covered.

[6] To see whether the script catches anything, the first result was broken by hand: an answer number changed (two ways), a clause changed, a quote changed, a silent question answered, an answerable question marked "Not in the policy", a row deleted, the right article but the wrong paragraph. All 8 English edits were caught with exit code 1, and so were all 9 edits of the Korean result (inputs and outputs are in run/bad*.txt; not model output). One example:

console
$ python3 -I check.py en policy.en.txt bad9.en.txtrows: 10, quotes verified: 7, 'not in policy' answers: 3FAIL Q2: quote is not in paragraph 3 of article 5exit 1

The first version of the script missed two kinds of edit. It compared answer numbers with every number in the policy, and 85 is in Article 5 as another region's cap, so it now compares with the quote. And it read only the article number, so citing another paragraph of the same article passed; it now checks the paragraph too.

[7] The script cannot see these, so read them.

  • A quote being in the article does not mean the answer summarises it correctly. An answer that reverses the quote still passes. Read each answer next to its quote.
  • Question 1 asks about "a major city". The model matched it to "other major cities" in the policy, which is a reasonable reading but is the model's reading. If a region split matters, put a list in the policy.
  • That questions 8, 9 and 10 are silent is your judgment. In real use you do not know in advance which questions fall outside the policy, so read the Not in the policy rows and the cited rows alike against the policy.

#policy-faq#claude#prompt#citation