Skip to content

Document Comparison Part 1

Do you ever end up with a large pile of documents — reports, workbooks, slide decks, meeting notes — that are all supposed to describe the same project or the same client, but you suspect they don't actually agree with each other? Checking that by hand is nearly impossible. With just 20 documents, you'd need to compare every pair against every other pair to be sure you haven't missed a contradiction — that's 190 individual cross-checks. Nobody has time for that, and doing it manually is exactly the kind of task where mistakes and missed conflicts creep in.

In this two-part article, I'll show you how to use clearxx Assistant (your Chat tool) and the clearxx Agent & Build Workspace (including Cline) to build a small automation tool that finds these inconsistencies for you — flagging genuine conflicts between documents, and separately listing important single-document issues worth knowing about — with no programming knowledge required.

Part 1 (this article) walks you through the whole process, step by step, explaining what to do and why. Part 2 contains the four ready-made scripts referenced throughout this article, with their code, so you don't have to build them yourself.

The Approach: Scripts for Mechanics, AI for Judgment

The core idea is a hybrid: some steps are pure mechanics — reading a file, stacking tables together, formatting a spreadsheet — and those are handled by small, fixed Python scripts that never change and never need AI. Other steps genuinely require judgment — deciding what a sentence means, whether two differently-worded statements are about the same thing, whether two statements actually contradict each other — and those are handled by Cline's own AI, never by a script trying to guess at rules.

Stage What happens Uses AI?
Read a file Pull out raw text with location markers (page, slide, row) ❌ No — a fixed script
Classify the content Decide fact / rule / status / issue for each piece of text ✅ Yes — Cline's judgment
Combine files Stack all the extracted tables into one ❌ No — a fixed script
Group into topics Decide which statements from different files are about the same subject ✅ Yes — Cline's judgment
Compare within topics Decide if statements sharing a topic agree or conflict ✅ Yes — Cline's judgment
Split for comparison (if needed) If the topic table is too large for one pass, split it without ever cutting a topic in half ❌ No — a fixed script
Build the report Turn the results into a formatted Excel file ❌ No — a fixed script

Keep this table in mind as you go — every step below tells you which tool is involved and whether it's a mechanical step or one that needs Cline's own reasoning.


Step 1: Explain Your Project to clearxx Assistant

Interaction: Discuss.

Before touching any files, open a chat with clearxx Assistant and explain, in your own words, what this project is about: what kind of documents you have, roughly how many, what they're supposed to describe, and what you suspect might be inconsistent between them. Ask the Assistant what challenges it would expect with a task like this.

This isn't a technical step — it's just making sure the Assistant has the right picture before you start planning anything. Everything that follows builds on this shared understanding.

Step 2: Give clearxx Assistant a Small Sample to Look At

Interaction: Provide sample data directly in the chat.

Take two of your documents and strip them down into small, cleaned-up excerpts — real content, but short and with anything sensitive or unnecessary removed. Then paste these small samples directly into the chat input field of the clearxx Assistant, or add them to the chat as files (see below).

This is an important distinction, and worth understanding early:

  • By default, the Assistant does not read a file completely, whether it is in a chat, in a Folder, or in a Workspace/Knowledge. Whenever you ask a question, it only gets the small pieces of the file that seem relevant. That's great for large archives you'll search occasionally, but it's the wrong mode here.
  • For this planning step, you want the Assistant to see the entire small sample, all at once — this is called giving it full context. Text you paste into the chat input field always arrives complete. For a file, click on the file above the input field to open its preview and flip the switch at the top right, so that it reads Using Entire Document. Only then can it actually judge the real layout, structure, and tone of your documents well enough to help you plan the rest of this project.

This also previews something important for later: Cline itself always reads full documents directly, never just the best-matching pieces. So the cleanup work you do now, on this small sample, is a preview of the same kind of cleanup you'll eventually need to do to all your source files before Cline works through them for real (see Step 4).

Step 3: Decide on the Scripts

Interaction: Discuss, then either reuse or create.

Now that clearxx Assistant has seen a real sample of your documents, discuss what scripts this project actually needs. This article provides four ready-made, tested scripts in Part 2 that cover a general version of this workflow — reading files, combining tables, splitting large tables, and building the final Excel report — so in many cases you can simply reuse those.

But it's worth understanding how this decision normally gets made, since your next project might be different: you would describe to clearxx Assistant what kind of mechanical steps you need done, and it helps you figure out what scripts are required. If a script is short and simple, clearxx Assistant can often write it directly in the chat. For anything longer or more involved, you would give the job to Cline, the same way it's used later in this article — Cline is much better suited to building and testing larger pieces of code.

Step 4: Prepare Your Files

Interaction: Discuss, plus manual cleanup by you.

Apply the same kind of cleanup you did on your small sample in Step 2 — but now to all your source files:

  1. For spreadsheet files — remove or ignore sheets that are pure reference data with no real content to compare.
  2. For slide decks — strip out anything not needed for the analysis: images, title slides, section dividers. Keep the text.
  3. Clean up file names — don't include the file extension as part of the name itself, and avoid & or other special characters.
  4. Confirm scope — check with whoever owns the documents whether any specific content is definitely not needed for this analysis, and remove it.

You can ask clearxx Assistant for guidance at any point during this cleanup if you're unsure what to keep or remove.

Step 5: Plan the Folder Structure

Interaction: Discuss.

Before opening the clearxx Agent & Build Workspace, talk through the folder structure with clearxx Assistant so you know exactly where everything will live. A structure like this works well:

On your own computer (before you start, and where the finished report lands at the end):

Your-Analysis-Project/           ← any folder name you like
├── scripts/                     ← the four scripts from Part 2
├── source-files/                ← all your original documents
└── final-report/                ← empty for now — the finished report goes here later

In the clearxx Agent & Build Workspace — Explorer:

Z_your-analysis/                  ← create this directly under CLEARXX (WORKSPACE)
├── scripts/                      ← the four fixed scripts
├── source-files/                 ← all your source documents, uploaded here
├── extracted/                    ← created automatically: one CSV per source file
├── master-claims.csv             ← created automatically: all extracted claims combined
├── topic-groups.csv              ← created automatically: claims grouped by topic
├── compare-batches/              ← only needed if topic-groups.csv turns out large
└── results/
    └── inconsistency-report.xlsx ← your finished deliverable

A tip: naming your workspace folder starting with Z_ (e.g. Z_your-analysis) makes it sort to the bottom of the Explorer's folder list, which keeps it easy to find alongside your other work.


Step 6: Develop the Extraction Instructions for Cline — Through Testing

Interaction: Discuss → Hand off to Cline → Review → Refine → Repeat.

This is the step where you turn your documents into a simple, structured list of statements — facts, rules, statuses, and issues — one row per statement. Getting this right isn't a one-shot conversation: you build the instruction through a short loop of testing and adjusting, using your small samples from Step 2, before you ever run it on your real, full set of documents.

  1. Discuss with clearxx Assistant, and ask specifically for a ready-to-paste instruction for Cline. Tell clearxx Assistant, in plain words, what you want Cline to do with each file: read it using the extraction script, then decide whether each piece of text it finds is a fact (a stated piece of information), a rule (if X happens, then Y is required), a status (something marked open, pending, or resolved), or an issue (a documented problem or gap). Ask the Assistant to turn this into a first-draft instruction you can hand to Cline directly. Again, for your project you may have a different approach — just discuss it with clearxx Assistant.

Also ask the Assistant to make sure the instruction tells Cline to save the output file using terminal commands only — never a file-editing tool — and to verify afterward that the file actually exists with a quick terminal check. This matters because a file-editing tool has been known to report success even when nothing was actually written to disk, which can be easy to miss if you don't check.

  1. Test it (Cline): Run this first-draft instruction with Cline, but only on one of your small sample file(s) — not the full real dataset yet. This keeps each round of testing fast.

  2. Review the result (clearxx Assistant): Take what Cline produced and show it to clearxx Assistant, along with Cline's own comments. Ask: did Cline capture everything important? Did anything get miscategorized? Did it miss something, or invent something that isn't really there?

  3. Explain problems in plain language, and refine: If something's off, just describe it to clearxx Assistant in your own words — for example: "some pages repeat almost the same content twice, and it counted both," or "this sentence is both a fact and something that triggers an action — I want that treated as a rule," or "this spreadsheet has a default-value column that isn't the same as an actual recommendation — don't flag a mismatch there as a problem." clearxx Assistant updates the instruction to handle the case you found.

  4. Test again: Run the updated instruction on the same sample (or a second one) with Cline. Confirm the problem is actually fixed, and that nothing new broke.

  5. Repeat as needed: Go through discuss → test → review → refine as many times as it takes until the instruction reliably produces good results with no further corrections needed.

  6. Lock it in: Once you're satisfied, this becomes your fixed instruction — from here on, reuse it unchanged for every real file in Step 7, without editing it between runs.

You'll go through this same discuss → test → review → refine loop again in Steps 9 and 10 when you develop the grouping and comparison instructions — it's the reliable way to end up with something you can trust to run unattended.

Step 7: Run Extraction on Every File

Interaction: Hand off to Cline, one file at a time, then Review, with in-task rework if needed.

Now apply your finished, locked-in instruction to every real source file:

  1. Open Cline in the Agent & Build Workspace.
  2. Start a new Cline Task for each file — don't continue the same task/conversation from the previous file. Click the + at the top of the Cline panel to start a fresh task.
  3. Give Cline your instruction along with the path to one file. Cline runs the extraction script on it, classifies what the script found, and saves the result as a CSV in your extracted/ folder.
  4. Before moving to the next file, confirm the CSV was actually created — you can ask Cline to run a quick line-count command if you're unsure.
  5. Review with clearxx Assistant. Take the resulting CSV and Cline's own comments, show both to clearxx Assistant, and ask it to check whether anything important seems to have been missed. Ask the Assistant to give you a prompt for Cline to fix things. If something was missed, don't start a new task — ask Cline to fix things within the same task rather than starting a new one. Only move on to the next file once this one is confirmed good.
  6. Remember, if needed, to let the clearxx Assistant help you update the prompt which you use to start each task for processing a new document. Remember this for later steps as well.

Repeat for every source file, always as a fresh task, always reviewed before moving on.

Step 8: Combine the Extracted Files

Interaction: Hand off to Cline for a mechanical script step, then a quick self-check.

Once every file has been processed, start a new Cline Task and have it run the combine script on your extracted/ folder, producing master-claims.csv. This step is pure mechanics — stacking tables together — so no AI judgment is involved here.

Afterward, do a quick sanity check yourself: does the row count roughly match the sum of all the individual files? Do all your expected source file names appear in the combined table? If anything looks off, don't move on — flag it to Cline to fix, or show the result to clearxx Assistant and ask for help figuring out what went wrong.

Step 9: Develop the Grouping Instructions and Group Claims into Topics

Interaction: Discuss → Test on a sample → Review → Refine → then Hand off to Cline as one single task on the full file → Review.

This step decides which statements from different files are actually about the same real-world subject — even if they're worded completely differently. Follow the same discuss → test → review → refine loop from Step 6 first, using your combined sample data, to arrive at a reliable instruction. Again, depending on your project, you may approach this differently.

Discuss with clearxx Assistant, and ask specifically for a ready-to-paste instruction (prompt) for Cline — the same as in Step 6. Explain what grouping means here (statements about the same real-world subject belong together, even if worded differently) and ask the Assistant to turn this into a prompt you can hand to Cline directly.

One rule matters more than any other here: this step must always run as a single Cline task over the entire combined file, never split into batches. If the data were split into pieces that couldn't see each other, two related statements from different files could land in different batches and never be recognized as belonging together — and every later step depends on that recognition happening correctly. Make sure the instruction you get from clearxx Assistant says this explicitly, so Cline doesn't try to split the work up on its own.

This step also involves Cline writing a small amount of code, and that's worth planning for carefully. Grouping itself must always be decided by Cline actually reading and judging each statement — never by a script matching keywords or fixed rules. But once every statement's topic has been decided, Cline does need to write the final result out as a CSV file, and this is where things can quietly go wrong if the instruction isn't specific enough. When you discuss this step with clearxx Assistant, make sure the resulting instruction for Cline covers:

  • Code is only for saving the result, never for deciding topics. The instruction should make clear that any script Cline writes is allowed to do exactly one thing — save the topics Cline has already worked out by reading — and must never be used to assign topics itself through keyword matching or hardcoded rules.
  • Attach each topic to its row using something unique from that row itself — for example the combination of file name and location — never by counting position or keeping a running number. A running count is easy to lose track of partway through a long file, and the mistake is invisible until you happen to check the exact row it affected.
  • Keep all the work in one place, run once. If saving the result takes several separate commands (common with a long file), everything should still build up in the same single script, run once at the very end — not several separate, disconnected commands. Separate runs don't remember each other, so part of the work can silently go missing.
  • Check the count before saving. Ask for a check that the number of topics assigned matches the number of rows in the input file, and to stop with an error rather than save an incomplete result if they don't match.

You don't need to know why each of these matters technically — just make sure the instruction clearxx Assistant gives you for Cline explicitly covers all four points above before you use it for real. If, while reviewing a result with clearxx Assistant, something looks like a row got the wrong topic, or rows seem to be missing, this is the first place to look.

A few more things worth knowing as you refine this instruction with clearxx Assistant:

  • Topics should be specific real-world subjects, not broad general categories. A handful of large, vague topic groups is usually a sign the instruction needs tightening.
  • Which file a statement came from should have no influence on how it gets grouped — two statements from the same file can end up in different topics, and two statements from different files can end up in the same topic.

Once you've tested and refined the instruction on a sample and you're confident in it, run it for real as one single Cline task over your full master-claims.csv, producing topic-groups.csv. Afterward:

  • Check that the line count of topic-groups.csv matches master-claims.csv — grouping only adds a label to each row, it never adds or removes rows.
  • Spot-check: pick two statements you already know are related but come from different files, and confirm they landed in the same topic.

If either check fails, don't move on — something needs fixing first.

Step 10: Develop the Comparison Instructions and Compare Claims Within Each Topic

Interaction: Discuss → Test on a sample → Review → Refine → then Hand off to Cline → Review.

This is where you find the actual inconsistencies. Within each topic group, Cline decides what to do:

  • Genuine conflict: two or more statements in the same topic clearly disagree — different facts, contradictory rules, or a status mismatch (one source says something is still open, another says it's already resolved).
  • Single-source issue: a topic contains at least one statement classified as an "issue" — worth surfacing even if nothing else in that topic actually disagrees with it. A real documented problem doesn't stop being worth knowing about just because it was only mentioned once, or because it was restated in similar words twice within the same document.
  • Skip: a topic where everything genuinely agrees, and nothing in it is an "issue," doesn't need to be flagged at all.

Discuss with clearxx Assistant, and ask specifically for a ready-to-paste instruction for Cline — the same as in Steps 6 and 9. Explain the three outcomes above in your own words and ask the Assistant to turn this into a prompt you can hand to Cline directly. The instruction should also tell Cline exactly what to output for each flagged topic: the topic, the type of finding, a plain-language description, the sources and locations involved, and the original quotes.

Go through the same discuss → test → review → refine loop as before, using your sample data, before running this for real. A few details worth making sure your instruction from clearxx Assistant explicitly covers:

  • Topic names must always be copied exactly from the input file into the results — never reworded or paraphrased. A paraphrased topic name in the output that doesn't actually exist in the input file is a sign something needs correcting. Ask clearxx Assistant to include this explicitly in the instruction for Cline.
  • Ask for a completeness recheck before Cline finalizes its list — a final pass back through every topic containing an "issue," to confirm none were accidentally left out while compiling the results. This should also be spelled out explicitly in the instruction, not left implied.
  • If Cline needs to write any code to help compile or save the output, the same rule from Step 9 applies: code is only for mechanical work like writing the final CSV, never for deciding whether something is a conflict or an issue — that decision must always come from Cline actually reading and judging the statements.

If, while reviewing a result with clearxx Assistant, you notice a topic name that doesn't match anything in your input file, or a finding that seems to have been dropped, these are exactly the kinds of problems this step's instruction is meant to prevent — describe what you found and ask clearxx Assistant to tighten the instruction further.

If your topic-groups.csv file turns out to be large (as a rough guide, more than roughly 150 rows), this step — unlike grouping — is safe to split into batches. Once every statement already has its correct topic assigned, comparing statements within one topic never needs to see statements from a different topic, so splitting doesn't reintroduce the same risk it did in Step 9. Use the split_by_topic.py script (see Part 2) to split the file without ever cutting a single topic across two batches, run the comparison instruction once per batch (each as its own new Cline task), and then use the combine script to merge the flagged results back into one file.

The output of this step is flagged-inconsistencies.csv — with columns for the topic, the type of finding, a plain-language description, the sources involved, the original quotes, and two empty columns (priority and status) for you to fill in yourself during review.

Step 11: Build the Excel Report

Interaction: Hand off to Cline for a mechanical script step.

Start a new Cline Task and have it run the Excel-conversion script on your flagged-inconsistencies.csv, producing a formatted inconsistency-report.xlsx in your results/ folder — bold header row, column widths auto-fit to the content. No AI judgment is needed here; it's a straightforward formatting step. Confirm the file appears where expected before moving on.

Step 12: Review the Results Yourself

Interaction: Human only.

Download inconsistency-report.xlsx and go through it row by row, checking each description against its quoted source text. Fill in the priority and status columns yourself as you review.

Keep in mind: this tool is a first-pass filter, not a final verdict. It may occasionally group things together that aren't really the same topic, or miss a real conflict that was phrased very differently across two documents. Your own read-through is still the last and most important step.


What Comes Next

That covers the entire workflow, from a folder full of unsorted documents to a reviewed spreadsheet of flagged inconsistencies. The four scripts referenced throughout this article — for reading files, combining tables, splitting large tables, and building the final Excel report — are provided with their full code in Part 2, ready to drop into your own scripts/ folder and reuse exactly as described above.