Chain-of-Custody Case Tracker
What you'll learn
~25 min- Build a chain-of-custody tracker with a single AI prompt
- Log evidence items with grid coordinates, timestamps, and custodian transfers
- Generate printable custody receipts using CSS @media print styling
- Visualize case timelines and transfer histories with Chart.js
What you’re building
Imagine arriving at an excavation site in the Pacific — a WWII-era battlefield where a recovery team has just uncovered skeletal remains and personal effects in a burial trench. Every bone fragment, every soil sample, every corroded metal artifact must be cataloged with precise timestamps and location data. Every time an item changes hands — from excavator to anthropologist to lab courier — that transfer gets documented. If a single link in the chain is missing, the evidence can be challenged and identification delayed by months.
Right now that documentation happens on paper forms in tropical humidity. A digital tracker that runs in a browser — even offline once loaded — would let the field team log everything in real time and print custody receipts at the end of each day.
That is what you will build in the next 20 minutes.
This tool demonstrates chain-of-custody concepts for training purposes. Real forensic work requires validated, accredited evidence management systems that meet federal chain-of-custody standards.
By the end of this lesson you will have a chain-of-custody case tracker that runs entirely in the browser. It handles case entry, evidence item logging, custodian transfer records, a timeline visualization with Chart.js, and printable custody receipts. You will build it by giving a single, carefully-crafted prompt to an LLM CLI tool.
Capture structured data, maintain an immutable transfer log, generate formatted output. This pattern works for equipment checkout systems, sample tracking, shipping manifests, any workflow where provenance matters.
🔍Domain Primer: Key forensic recovery terms
New to forensic recovery operations? Here are the key terms you will encounter:
- Chain of custody — The documented, unbroken record of who possessed a piece of evidence, when, and why. If the chain is broken (a gap in documentation), the evidentiary value can be challenged.
- Evidence item — Any physical object recovered during an excavation: skeletal elements, soil samples, personal effects, munitions fragments, uniform buttons, dental prosthetics.
- Grid square — Excavation sites are divided into a coordinate grid (e.g., N24-E15 means 24 meters north, 15 meters east of the datum point). Every item’s location is recorded by grid square and depth.
- DPAA — Defense POW/MIA Accounting Agency. The U.S. Department of Defense organization responsible for recovering and identifying missing service members from past conflicts.
- Provenience — The precise three-dimensional location where an item was found. Includes grid square, depth below surface, and spatial relationship to other items.
- Field recovery — The process of systematically excavating a site, screening soil for fragments, and documenting every find in situ before removal.
- Skeletal element — An individual bone or bone fragment. Forensic anthropologists identify each element (e.g., “left femur, proximal third”) to determine minimum number of individuals.
- Commingling — When remains from multiple individuals are mixed together in the same burial context. Common in mass graves and battlefield recoveries.
- Accession number — A unique identifier assigned to a set of remains when they enter the laboratory system. Links field recovery data to laboratory analysis.
You do not need to be an expert in forensic recovery — the AI tool will handle the technical implementation. You just need to know what the tracker is documenting and why.
Who this is for
- Forensic anthropologists and recovery team members who need a faster way to log evidence in the field.
- Lab coordinators who receive evidence shipments and need to verify custody documentation.
- Students in forensic science or bioarchaeology courses learning chain-of-custody principles.
The showcase
Here is what the finished tracker looks like once you open the HTML file in a browser:
- Case dashboard at the top showing total cases, total evidence items, and total transfers.
- Case entry form for creating new cases (case number, site designation, GPS coordinates, recovery team lead).
- Evidence item log for each case — item number, description, grid square, depth, condition, recovered-by, date/time.
- Transfer log — every custody change recorded with from-person, to-person, date/time, and reason.
- Timeline visualization (Chart.js horizontal bar chart) showing the chronological sequence of recoveries and transfers for each case.
- Printable custody receipt — a button that opens a print-friendly view with all items, transfers, and signatures lines, styled with CSS
@media print.
Everything runs client-side. No data leaves the browser. The sample data loads instantly so you can see the full workflow before entering your own cases.
The prompt
Open your terminal Terminal The app where you type commands. Mac: Cmd+Space, type "Terminal". Windows: open WSL (Ubuntu) from the Start menu.
Full lesson →
, navigate to a project folder project folder A directory on your computer where the tool lives. Create one with "mkdir my-project && cd my-project".
Full lesson →
, start your AI CLI tool AI CLI tool Claude Code, Gemini CLI, or Codex CLI — a command-line AI that reads files, writes code, and runs commands.
Full lesson →
(e.g., by typing claude), and paste this prompt:
Build a single self-contained HTML file called custody-tracker.html that serves asa chain-of-custody case tracker for forensic field recovery operations. Requirements:
1. PRELOADED SAMPLE DATA (embed as a JS array on page load) Two cases with evidence items and transfer histories:
Case DPAA-2024-0147: Site: "Tarawa Atoll Recovery Site 3", GPS: 1.4518°N 172.9717°E Team Lead: "Dr. Sarah Mitchell" Items: - CUS-0147-001: "Left femur, proximal fragment", Grid N24-E15, Depth 1.2m, Condition "Fair - surface erosion", Recovered by "SSgt Torres", 2024-03-15 08:30 Transfers: Torres → Dr. Mitchell (08:45, "Field examination"), Dr. Mitchell → Lab Courier Daniels (17:00, "End of day transport") - CUS-0147-002: "Soil sample A-3", Grid N24-E15, Depth 1.2m, Condition "Sealed in sample bag", Recovered by "Sgt Park", 2024-03-15 09:10 Transfers: Park → Dr. Mitchell (09:20, "Cataloging"), Dr. Mitchell → Lab Courier Daniels (17:00, "End of day transport") - CUS-0147-003: "Personal effects - corroded wristwatch", Grid N25-E15, Depth 0.9m, Condition "Corroded, partial band", Recovered by "SSgt Torres", 2024-03-15 10:45 Transfers: Torres → Dr. Mitchell (11:00, "Photography and cataloging"), Dr. Mitchell → Evidence Specialist Rivera (14:30, "Artifact conservation") - CUS-0147-004: "Right humerus, complete", Grid N24-E16, Depth 1.3m, Condition "Good - minor root damage", Recovered by "Sgt Park", 2024-03-15 13:20 Transfers: Park → Dr. Mitchell (13:35, "Osteological assessment")
Case DPAA-2024-0152: Site: "Chosin Reservoir Survey Area 7", GPS: 40.4543°N 127.2460°E Team Lead: "Dr. James Whitfield" Items: - CUS-0152-001: "Mandible fragment with 3 teeth", Grid S08-W22, Depth 0.6m, Condition "Good - teeth intact", Recovered by "Cpl Nguyen", 2024-04-02 07:15 Transfers: Nguyen → Dr. Whitfield (07:30, "Dental charting"), Dr. Whitfield → Odontologist Dr. Keane (09:00, "Dental comparison") - CUS-0152-002: "Dog tag fragment - partial text", Grid S08-W23, Depth 0.5m, Condition "Corroded, partial stamping visible", Recovered by "Sgt Olsen", 2024-04-02 08:00 Transfers: Olsen → Dr. Whitfield (08:15, "Photography"), Dr. Whitfield → Evidence Specialist Kim (10:00, "Electrolytic cleaning") - CUS-0152-003: "Left tibia, distal half", Grid S09-W22, Depth 0.7m, Condition "Fair - old fracture visible", Recovered by "Cpl Nguyen", 2024-04-02 09:45 Transfers: Nguyen → Dr. Whitfield (10:00, "Measurement and documentation") - CUS-0152-004: "Uniform button, USMC eagle globe anchor", Grid S08-W23, Depth 0.5m, Condition "Corroded but identifiable", Recovered by "Sgt Olsen", 2024-04-02 08:10 Transfers: Olsen → Dr. Whitfield (08:20, "Historical artifact assessment")
2. CASE MANAGEMENT - Case list sidebar showing all cases with item counts - Case detail view with all items and transfers - New case form: case number, site designation, GPS coordinates, team lead, date - New evidence item form: auto-incrementing item number, description, grid square, depth (meters), condition, recovered by, date/time - New transfer form: select item, from person, to person, date/time, reason
3. TIMELINE VISUALIZATION - Chart.js horizontal bar chart showing events per case on a time axis - Recovery events in blue, transfer events in amber - Hovering shows full details (item, persons, reason) - One bar per event, grouped by case
4. PRINTABLE CUSTODY RECEIPT - "Print Receipt" button for each case - Opens a print-friendly layout using CSS @media print: hide navigation, show case header, list all items with descriptions and grid locations, list all transfers in chronological order, include blank signature lines for "Released by" and "Received by", include date/time fields - Receipt header: case number, site, GPS, team lead, date range of recovery
5. DASHBOARD - Top bar showing: total cases, total evidence items, total transfers, date range across all cases - Case summary cards with item counts and latest transfer status
6. DESIGN - Dark theme: background #0f172a, cards #1e293b, text #e2e8f0, accent #10b981 - Clean sans-serif font (Inter from Google Fonts CDN) - Responsive layout with sidebar for case list, main area for case details - Color-coded item condition: Good = green badge, Fair = yellow, Poor = red
7. TECHNICAL - Pure HTML/CSS/JS in one file, no build step - Chart.js loaded from CDN (https://cdn.jsdelivr.net/npm/chart.js) - All data stored in a JS array (no localStorage needed for this prototype) - @media print CSS hides everything except the receipt contentThat entire block is the prompt. Paste it as-is. The specificity is deliberate — the more precise you are about requirements, the closer the first output will be to what you actually want. Vague prompts produce vague tools.
What you get
After the LLM finishes (typically 60-90 seconds), you will have a single file: custody-tracker.html. Open it in any browser.
Expected output structure
custody-tracker.html (~700-1000 lines)You should see:
- A dashboard bar at the top showing 2 cases, 8 evidence items, and 13 transfers.
- A sidebar listing both cases — clicking either one shows its detail view.
- Each case displays its evidence items as cards with grid square coordinates, depth, and condition badges.
- Transfer histories appear as a chronological log under each item, showing who handed what to whom and why.
- A timeline chart showing recovery events (blue) and transfer events (amber) plotted across the day.
- Clicking “Print Receipt” opens a clean, black-and-white receipt layout ready for printing.
If something is off
| Problem | Follow-up prompt |
|---|---|
| Timeline chart is blank | The Chart.js timeline is not rendering. Make sure the chart is created after the DOM is loaded and the data is formatted as horizontal bar segments with start/end times. |
| Print layout shows the whole page | The @media print CSS is not hiding the sidebar and dashboard. Add display:none to the sidebar, dashboard bar, and form sections inside a @media print block. Only the receipt div should be visible. |
| Transfer form does not show item list | The transfer form dropdown for selecting an item is empty. Populate it from the current case's evidence items array when the form opens. |
When Things Go Wrong
Use the Symptom → Evidence → Request pattern: describe what you see, paste the error, then ask for a fix.
How it works (the 2-minute explanation)
You do not need to understand every line of the generated code, but here is the mental model:
- Case data structure is a JavaScript array of objects. Each case has metadata (number, site, GPS, team lead) and arrays of evidence items and transfers. This mirrors how a relational database would model the same data.
- Evidence items each get a unique ID derived from the case number. The grid square and depth record provenience — the exact location in three-dimensional space where the item was found.
- Transfer log is append-only. Each entry records who had the item, who received it, when, and why. This creates an auditable chain. The key principle: transfers are never edited, only added.
- Chart.js timeline plots events as horizontal bars on a time axis. Recovery events and transfer events use different colors so you can see the workflow pattern — items are recovered in the morning, examined during the day, and transferred at end of day.
- CSS @media print is a built-in browser feature that applies different styles when you print or save as PDF. The receipt hides all interactive elements and shows only the formatted evidence list with signature lines.
Paper-based chain-of-custody forms are the standard in forensic fieldwork, but they have known failure modes: illegible handwriting, forms damaged by weather, gaps when a transfer is forgotten, and hours spent transcribing paper records into digital systems back at the lab. A browser-based tracker does not replace the legal requirement for signed forms, but it provides a parallel digital record that catches errors in real time. The printable receipt bridges the gap — you maintain the digital log and print the paper form from the same data source.
Customize it
The base tracker handles the core workflow, but real field operations have additional needs. Each of these is a single follow-up prompt:
Add photo documentation placeholders
Add a photo section to each evidence item card. Include a file upload area(drag-and-drop zone) that accepts JPG/PNG images. Display uploaded photos asthumbnails in the item card. Store the images as base64 data URLs in the itemobject. On the printed receipt, show photo placeholders with "Photo attached -see digital record" text.Add GPS map visualization
Add a small map view for each case using Leaflet.js (load from CDN). Plot eachevidence item as a marker on the map using the case GPS coordinates as thecenter point. Since individual items do not have separate GPS coordinates,offset them slightly based on their grid square relative to the site datum.Color markers by item condition (green/yellow/red).Add export to CSV
Add an "Export CSV" button that downloads all evidence items and transfers forthe selected case as a CSV file. Include columns: Case_Number, Item_ID,Description, Grid_Square, Depth_m, Condition, Recovered_By, Recovery_DateTime,Transfer_From, Transfer_To, Transfer_DateTime, Transfer_Reason. Each transfergets its own row with the item data repeated.Notice the pattern: you start with a working tool, then add features one prompt at a time. Each prompt builds on what already exists. This is how all the tools in this track are built — iteratively, starting from a solid foundation. You never need to plan the entire tool upfront.
Try it yourself
- Open your CLI tool in an empty folder.
- Paste the main prompt from above.
- Open the generated
custody-tracker.htmlin your browser. - Click through the sample data — examine both cases, review their items and transfers.
- Try adding a new evidence item and recording a transfer.
- Click “Print Receipt” and save as PDF.
- Pick one customization from the list above and add it.
Key takeaways
- One prompt, one tool: a detailed, specific prompt produces a working chain-of-custody tracker in under 2 minutes.
- Single-file HTML tools bypass all installation barriers — they run on any computer with a browser, which makes them ideal for field laptops and shared workstations.
- Chain of custody requires append-only logging — transfers are never edited, only added. This principle should be built into the tool from the start.
- CSS @media print is a powerful, underused feature — it lets you generate printable documents from the same tool that manages digital records.
- Embedded sample data makes tools immediately testable — you can verify the tool works before entering real data.
Why is an unbroken chain of custody critical in forensic identification work?
What information must every custody transfer record include?
How does a digital chain-of-custody tracker improve on paper forms for field recovery operations?
What’s next
In the next lesson, you will build a Forensic STR Profile Matcher — a tool that visualizes degraded Short Tandem Repeat allele calls side-by-side against reference profiles, color-codes matches and mismatches, and calculates match statistics for triage. Same pattern: one prompt, one working tool, then customize.