{
  "id": 8413471,
  "title": "I Built a CBT Thought Journal in 50 Lines of Python 🧠",
  "url": "https://urgent.news/2026/09/19/i-built-a-cbt-thought-journal-in-50-lines-of-python",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-09-19T08:12:31.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/473185670/i-built-a-cbt-thought-journal-in-50-lines-of-python-3ilb"
  },
  "original_language": "en",
  "account": "Last week, the author realized they were prone to thinking: \"I always mess everything up.\" This thought is an example of overgeneralization, a cognitive distortion where a single mistake is perceived as a complete failure. The author wanted to check this immediately, so they created a journal that automatically flags cognitive distortions using a CBT Thought Analyzer API they deployed themselves. The API can identify 11 cognitive distortions, 8 procrastination patterns, and 4 attachment styles. The analysis is based on evidence-based keyword pattern matching and does not require an AI model.\n\nThe journal entry is implemented in 50 lines of Python code. It includes functions to analyze thoughts for cognitive distortions and procrastination patterns, as well as to write a journal entry with automatic CBT analysis. The code uses the requests library to send thoughts to the CBT analyzer API and the datetime library to add a timestamp to each journal entry. The author tested the journal with four example thoughts and received automatic analysis results for each one.\n\nThe output shows the timestamp, the thought, and any detected distortions or procrastination patterns. For each thought, the analyst provides a confidence percentage for each detected distortion or pattern, as well as suggested reframes or interventions. If no distortions or procrastination patterns are detected, the analyst notes that the thought appears balanced. The journal provides immediate feedback on thought patterns, helping users identify and challenge cognitive distortions and procrastination tendencies.",
  "summary": "Last week I caught myself thinking: \"I always mess everything up.\" My therapist would recognize this as overgeneralization — a cognitive distortion where one mistake becomes \"everything.\" But I didn't want to wait for my next session to check. So I built a journal that flags distortions automatically, using a free API I deployed myself. Here's the whole thing in 50 lines. The API: CBT Thought…",
  "key_points": [
    "Author created CBT Thought Analyzer API to flag cognitive distortions",
    "50 lines of Python code implement journal with automatic analysis",
    "Output provides timestamp, thought, and detected distortions/patterns"
  ],
  "editors_take": null,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}