Logs Before Intelligence: Why Data Discipline Must Precede AI Insight
Before you build any AI feature, you must first build the log. The principle every physician-developer needs to internalize before writing a single line of intelligence code.
By Dr. Chukwuma Onyeije, MD, FACOG
Maternal-Fetal Medicine Specialist & Medical Director, Atlanta Perinatal Associates
Founder, Doctors Who Code · OpenMFM.org · CodeCraftMD · · 8 min read
Listen to this post
The principle every physician-developer must internalize before building anything.
The Mistake Everyone Makes First
When physicians discover AI-assisted development, the instinct is immediate and understandable: build something intelligent. Build a recommendation engine. Build a diagnostic assistant. Build an agent that synthesizes data and produces insight.
I understand that instinct. I had it myself.
The problem is that intelligence without data is theater. An AI system that has nothing reliable to reason over will produce confident-sounding output that is either generic, wrong, or both. You will build a system that feels impressive in a demo and fails in daily use. You will lose trust in the tools you built. You will lose trust in the data. And eventually, you will stop using the system altogether.
I have watched this happen to projects I have been part of. I have felt it in my own work. And the lesson I have internalized from years of building at the intersection of clinical medicine and software development is this:
Logs before intelligence. Always.
What “Logs Before Intelligence” Actually Means
The principle is simple. Before you build any layer of analysis, recommendation, prediction, or AI-assisted synthesis, you must first build a system that reliably captures raw, structured, timestamped data. That is the log. The log is the ground truth. Everything else is interpretation of the log.
This is not a technology argument. It is an epistemological one.
You cannot reason accurately over data you do not have. You cannot detect trends in data that was never captured. You cannot trust AI-generated insights derived from inconsistent, incomplete, or improperly structured inputs. The quality of every intelligent output is bounded by the quality of the underlying log.
In medicine, we understand this intuitively. We do not diagnose from impressions. We diagnose from records. The chart, the labs, the imaging, the vital signs trend over time: these are the logs. The clinical assessment is the intelligence layer applied to those logs. You would never attempt to manage a critically ill patient from memory alone. The documentation is not bureaucracy. It is the data substrate that makes sound reasoning possible.
The same principle applies to every AI-powered system we build as physician-developers.
The PGIS: A Working Demonstration
The most concrete example in my own work is the Performance Glycemic Intelligence System.
PGIS is a personal AI-powered dashboard I built to manage the intersection of endurance training, continuous glucose monitoring, and cardiovascular health. It integrates data from my Libre 3 Plus CGM, my Garmin wearable, sleep quality scores, and training load into a daily readiness assessment. It generates structured daily reports, training recommendations, and metabolic narratives.
People see the outputs and think: that is the system. The narratives, the recommendations, the trend analyses. That is where the value lives.
That is wrong. The value lives in the logs.
Every morning before PGIS can tell me anything useful about my HRV, my glycemic variability, or my readiness to train, it needs clean, timestamped, structured records from the previous 24 hours. CGM readings tied to exact times. Garmin metrics logged in consistent formats. Sleep data captured in the same schema every night. Subjective readiness scores entered at the same cadence.
When I skip a day of logging, the system does not just have a gap. It has a corrupted context. The rolling averages drift. The trend lines lose their anchor. The recommendations become less precise because the intelligence layer is now reasoning over incomplete ground truth.
The PGIS is only as good as the logs that feed it. That is not a limitation of the system. It is the defining constraint of every AI system ever built.
This Principle Scales Across Every Domain I Build In
What makes “logs before intelligence” a pillar principle rather than a PGIS-specific lesson is that it applies everywhere I have tried to build.
OpenMFM.org. Before I could build search, filtering, or any AI-powered feature for the MFM clinical knowledge platform, I needed a clean, structured manifest of every presentation in the library. A Python script, generate_data.py, parses raw HTML files and produces a master presentations.json with consistent fields: title, URL, tags, description. That JSON is the log. The application consumes it. The AI features will consume it. Nothing intelligent happens without that clean data layer in place first.
LifeOS-MD. When I designed my personal cognitive operating system for multi-domain capture across clinical work, theology, and training, the architectural decision I made before any other was: immutable logs first. The schema I built enforces two separate timestamps, one for when the experience occurred, one for when the system received it. Raw text is never modified after capture. Every entry is a permanent record. The intelligence layer, the synthesis, the pattern detection, the AI-assisted narrative, comes later. The log is sacrosanct.
CodeCraftMD. Before I can run AI-assisted ICD-10 and CPT extraction on clinical documentation, I need structured, reliable text inputs from the clinical encounter. The quality of the billing intelligence is directly downstream of the quality of the documentation log. Garbage in, garbage out is not a cliche. It is an architectural constraint.
PGIS Breathe. The HRV breathing application includes a Garmin HRV logging tab with a daily entry modal and a 30-day trend chart. I built the logging interface before I built the analytics. Not because the analytics are less important, but because without consistent logs, the analytics have nothing real to display.
The pattern is the same every time. Establish the log. Enforce the structure. Then build the intelligence.
The Three Properties Every Log Must Have
Not every data capture system qualifies as a proper log. I have learned, through building and breaking multiple systems, that a log supporting reliable AI reasoning must have three properties.
It must be immutable. Once a data point is captured, it should not be silently modified. You can annotate it. You can flag it. You can add context. But the raw record should remain intact. This matters because AI systems operating on data that shifts underneath them will produce output that cannot be reproduced or trusted. In LifeOS-MD, I enforced this at the schema level. The raw_text field has no update path. It is a permanent record of what was captured.
It must be timestamped with precision. Trends are meaningless without reliable time anchors. Two timestamps are better than one: when the event occurred and when the system received it. These are often different. A voice note captured at 11pm about a run completed at 7am needs both timestamps to be useful. PGIS requires this precision because the relationship between glucose readings and training stimuli is time-dependent. A glucose reading is not just a number. It is a number at a moment, in relation to what happened before and after.
It must be structured consistently. Intelligence scales on structure. A log entry that stores glucose readings as free text in one session and as numeric fields in another is not a log. It is a mess. Before you write a single line of AI integration code, define your schema. Decide what fields matter. Enforce their types. Write the validation. This work is unglamorous. It is also the most important work you will do, because every intelligent feature you build later will stand or fall on the quality of this foundation.
The Clinical Analogy That Makes This Concrete
Think about what it means to manage a high-risk obstetric patient across multiple encounters over months.
At each visit, you record vitals, labs, ultrasound findings, symptoms, and clinical decisions. Over time, those records accumulate into a longitudinal dataset that allows you to see trends, detect deterioration early, and make decisions with appropriate context.
Now imagine a colleague who sees patients but does not document consistently. Some visits are detailed. Others are a single line. Lab values are recorded in different units across different visits. The timeline is unclear. Three months later, when a patient presents in crisis, that colleague cannot reason accurately over the prior clinical course because the logs are inadequate.
You already know what happens in that scenario. The clinical outcome suffers because the data substrate was never disciplined enough to support sound reasoning.
AI systems work exactly the same way. The sophistication of the algorithm is irrelevant if the data it reasons over is inconsistent, incomplete, or imprecise. Every intelligent feature in every system I build is downstream of the log quality. Every time I have rushed past the logging layer to get to the “interesting” intelligence work, I have paid for it with systems that underperform and eventually erode my trust.
A Practical Framework for Building Logs First
When I start any new system now, I follow the same sequence before I write a single line of AI integration.
First, I define the atomic unit of capture. What is the smallest meaningful piece of data this system needs to record? For PGIS, it is a single timestamped biometric reading. For LifeOS-MD, it is a single timestamped log entry with raw text. For OpenMFM, it is a single presentation record in a structured JSON schema. I define this unit precisely before anything else.
Second, I build the capture mechanism. Not the analysis. Not the visualization. Not the recommendation engine. Just the system that reliably gets data from the real world into the log. For PGIS, that is the CGM integration and the Garmin sync. For LifeOS-MD, that is the Slack ingestion endpoint. For OpenMFM, that is the Python parsing script. The capture mechanism is the most critical piece of infrastructure in any data-dependent system.
Third, I enforce schema discipline. Types, constraints, validation. Required fields are required. Timestamps are required. I do not compromise on this in the early architecture because every compromise I make here costs me twice as much when I try to reason over the data later.
Fourth, and only fourth, I build the intelligence layer. Trend analysis. AI-assisted narrative generation. Recommendations. Predictions. Everything intelligent that makes the system feel valuable. This layer is built on the assumption that the logs beneath it are clean, consistent, and reliable. If that assumption is true, the intelligence is powerful. If it is not, the intelligence is noise.
Why This Matters More for Physicians Than Anyone Else
As clinicians, we are trained to reason over incomplete information. We make diagnoses under uncertainty. We act on partial data. This is a real and necessary clinical skill. But it is a dangerous design philosophy for software systems.
When we build AI tools for ourselves, for our patients, or for our practices, we are not supposed to be compensating for bad data with clinical judgment. We are supposed to be amplifying good data with intelligent systems. The physician-developer who understands this distinction will build fundamentally different, and fundamentally better, tools than one who does not.
The clinical insight we bring to software development is not just domain knowledge about medicine. It is the epistemological discipline we already apply to clinical records: document everything, maintain consistency, never overwrite ground truth, and reason from the record rather than from memory.
That discipline is the foundation of logs before intelligence. We already know how to do this. We just need to apply it to the systems we build.
The PGIS Breathe Moment
This week, when my PGIS flagged four consecutive days of low HRV and recommended structured breathing exercises to restore parasympathetic tone, the recommendation was trustworthy because the logs were trustworthy. The system had clean, consistent HRV data going back weeks. The trend was real. The pattern was real. The recommendation was grounded in actual data, not in hallucination or approximation.
That is what logs before intelligence makes possible: AI-generated insight you can actually act on, because the data it was derived from is reliable.
I built PGIS Breathe in response to that recommendation. The first thing I built in PGIS Breathe, before the animated breathing orb, before the Web Audio API integration, before the protocol library, was the HRV logging tab. A daily entry modal. A 30-day trend chart. The log.
Then I built the intelligence.
The Takeaway
If you are a physician-developer, or a physician who wants to start building, here is what I want you to carry from this post.
The AI features are not the foundation. The log is the foundation. Before you integrate a language model, before you build a recommendation engine, before you write any analytical feature, ask yourself: do I have clean, consistent, structured, timestamped data that this intelligence can reliably reason over?
If the answer is no, stop. Build the log first. Instrument the capture. Enforce the schema. Wait until you have enough ground truth to trust.
Then build the intelligence.
Not because the intelligence is less important. But because intelligence without disciplined logs is not intelligence. It is guessing with extra steps.
Logs before intelligence. Every time.
Newsletter
Enjoyed this post?
Get physician-developer insights delivered weekly. No hype. No filler.
Powered by beehiiv
Related Posts
I Didn't Download an App. I Described My Problem to an AI and It Built One for Me.
The EHR Vendor Wants You to Stay a Consultant
Your First Build Does Not Have to Save Lives
Chukwuma Onyeije, MD, FACOG
Maternal-Fetal Medicine Specialist
MFM specialist at Atlanta Perinatal Associates. Founder of CodeCraftMD and OpenMFM.org. I write about building physician-owned AI tools, clinical software, and the case for doctors who code.