<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Forrester Terry</title>
    <description>The latest articles on DEV Community by Forrester Terry (@sweetpapa).</description>
    <link>https://dev.to/sweetpapa</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F988039%2F6b9991e3-2671-4e47-9db2-206846065c1e.jpeg</url>
      <title>DEV Community: Forrester Terry</title>
      <link>https://dev.to/sweetpapa</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/sweetpapa"/>
    <language>en</language>
    <item>
      <title>Before You Build Anything With A.I., Write Down What Right Looks Like</title>
      <dc:creator>Forrester Terry</dc:creator>
      <pubDate>Tue, 29 Sep 2026 16:30:00 +0000</pubDate>
      <link>https://dev.to/sweetpapa/before-you-build-anything-with-ai-write-down-what-right-looks-like-o70</link>
      <guid>https://dev.to/sweetpapa/before-you-build-anything-with-ai-write-down-what-right-looks-like-o70</guid>
      <description>&lt;p&gt;The team meets. Everyone is excited. Someone opens a chat window and types "build us a dashboard that tracks our renewals." Twenty minutes later there is a dashboard. It has charts. It has a dark mode. It looks amazing.&lt;/p&gt;

&lt;p&gt;Then the person who actually handles renewals every month looks at it and says, "That number is wrong."&lt;/p&gt;

&lt;p&gt;Nobody can say why and nobody wrote down what right was supposed to be.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fzw9zbtlme9dl8heo7830.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fzw9zbtlme9dl8heo7830.jpg" alt="Two-panel cortisol meter meme. Left, blurry and shaking, " width="743" height="337"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Why this step matters so much
&lt;/h2&gt;

&lt;p&gt;A.I. is really good at making things that look finished. That's the magic, and it's also the trap.&lt;/p&gt;

&lt;p&gt;What it can't do is know what "right" means for your work. It doesn't know that a charge on the 3rd is normal but a charge on the 30th means someone forgot to cancel. It doesn't know which column in the export can't be trusted. You know that, or someone on your team does.&lt;/p&gt;

&lt;p&gt;That knowledge is the most valuable thing your team brings. Getting it out of people's heads and onto the page before anything gets built is where most of the win comes from.&lt;/p&gt;

&lt;h2&gt;
  
  
  What it looks like in practice
&lt;/h2&gt;

&lt;p&gt;Say the project is tracking software subscriptions. You have a list of what your team pays for, and a card statement of what actually got charged. The goal is to catch surprises.&lt;/p&gt;

&lt;p&gt;Before anybody prompts anything, write three examples by hand.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A normal one.&lt;/strong&gt; "Design tool, $15 a month, charged on the 5th, matches the list. Nothing to flag."&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A wrong one.&lt;/strong&gt; "Survey tool. The list says $20 a month. The card says $340. It renewed annually at a new price. Flag it."&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A weird one.&lt;/strong&gt; "A $9 charge from a vendor nobody recognizes. Not on the list at all. Flag it and find out who owns it."&lt;/p&gt;

&lt;p&gt;Three examples, ten minutes. Now you have something to hand the A.I., and something to check its work against. When the tool says "everything looks good," you can run your three and know whether that's true.&lt;/p&gt;

&lt;p&gt;The weird one is usually the most useful. It's where the real work lives, and it's the case the A.I. may quietly skip.&lt;/p&gt;

&lt;h2&gt;
  
  
  Tips for getting started
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;1. Start with a small slice of real data.&lt;/strong&gt; Twenty rows beats twenty thousand. You can read twenty rows yourself and spot what the A.I. gets wrong. Stick to data and tools you're allowed to use, and leave out anything sensitive you don't need.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Write your examples before you prompt.&lt;/strong&gt; One normal, one wrong, one weird. If you have issues here, you may need to spend more time sorting your data and approach. That's a great thing to find out on day one instead of week three.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Decide what "wrong" looks like.&lt;/strong&gt; One sentence is enough: "This is wrong if a charge shows up that isn't on the list." I wrote more about this in &lt;a href="https://fterry.su.domains/posts/checking-ai-work-is-hard" rel="noopener noreferrer"&gt;Checking A.I. Work is Hard&lt;/a&gt;. If you can't name what broken looks like, you'll end up with misleading results.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Pick the smallest version that helps someone next week.&lt;/strong&gt; Skip the full vision for now. Find the one piece that would save somebody real time on Monday. A spreadsheet of flagged charges is a win. The dashboard can come afterwards.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5. Let the person who knows the work be the judge.&lt;/strong&gt; On a mixed team, the most important person in week one often isn't the one writing code. It's the person who can look at an output and say "that's wrong, and here's why." If that's you, everyone on the team will need you.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;6. Make the A.I. ask questions first.&lt;/strong&gt; Give it your sample and your examples, and tell it not to build anything yet. Let it interview you. The questions it asks will show you what your team hasn't decided.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F31p99jq7uc3h4y6tzmu3.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F31p99jq7uc3h4y6tzmu3.jpg" alt="Three-panel comic of a cartoon dog. Panel one: " width="761" height="343"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Tips particularly for developers
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Turn the examples into tests.&lt;/strong&gt; Your team's hand-written cases can become your first test fixtures. Every change then gets checked against what the team said right looks like.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Don't let the agent edit the examples.&lt;/strong&gt; Keep them in their own file and mark it read only. If a test fails, the code is likely wrong, not the example. Agents love to "fix" a failing test by changing what it expects.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Add an example every time something surprises you.&lt;/strong&gt; Every bug the domain expert catches becomes a new case. By the end of the project you have a real test suite written by the people who know the work best.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Prove the logic before the interface.&lt;/strong&gt; A small script that reads the sample and prints the flags is a great first deliverable. Once the flags are right, the UI is the easy part.&lt;/p&gt;

&lt;h2&gt;
  
  
  Wrapping up
&lt;/h2&gt;

&lt;p&gt;The tools keep getting faster at building. Knowing what right looks like is still on us, and it's the part that makes everything else worth building.&lt;/p&gt;

&lt;p&gt;So before your team opens a chat window this week, grab a whiteboard, pull twenty rows, and write down three examples. It takes 10 minutes, and will be very worth it.&lt;/p&gt;

&lt;p&gt;Good luck to everyone kicking off something new.&lt;/p&gt;

&lt;h2&gt;
  
  
  Example prompts
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Before you start
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Here is a small sample of our data and three examples of what correct
output looks like, including one that should be flagged. Do not build
anything yet. Read everything, then ask me the questions you need
answered to get this right. Ask them one at a time.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Here is what we want to build: &amp;lt;one or two sentences&amp;gt;. What is the
smallest version of this that would still be useful to someone next
week? What would we leave out, and what would we lose by leaving it out?
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Writing your examples
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Here is a sample of our data. Help me write examples of correct output:
one normal case, one that is clearly wrong, and one edge case that is
easy to miss. Don't guess at our rules. If you are not sure how a case
should be handled, ask me.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Before it builds
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Before you build anything, restate in plain language what "done" means
for this project, and list how each of my examples should come out. If
anything I've told you conflicts, point it out.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  After it says it’s done
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Run my examples through what you built and show me the result for each
one next to what I said it should be. Do not change the examples. If
any don't match, tell me which ones and why.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;What kinds of cases did my examples NOT cover? Give me three new
examples I should add, and tell me how you currently handle each one.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  For developers
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Turn examples.md into test fixtures. Treat examples.md as read only.
If a test fails, fix the code, never the expected result. If you think
an example itself is wrong, tell me instead of changing it.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>ai</category>
      <category>requirements</category>
      <category>developers</category>
      <category>beginners</category>
    </item>
    <item>
      <title>26 Ways to Use Coding Agents for Non-Coding Tasks</title>
      <dc:creator>Forrester Terry</dc:creator>
      <pubDate>Tue, 15 Sep 2026 16:56:03 +0000</pubDate>
      <link>https://dev.to/sweetpapa/26-ways-to-use-coding-agents-for-non-coding-tasks-2lkc</link>
      <guid>https://dev.to/sweetpapa/26-ways-to-use-coding-agents-for-non-coding-tasks-2lkc</guid>
      <description>&lt;p&gt;Most people think of coding agents as tools for just writing code. But they can be effective for a lot more than that! If it has a command line, an API, or a screen, a coding agent can usually operate it. &lt;/p&gt;

&lt;p&gt;For this post I figured folks could jump around and look at what they find interesting. There is a quick table of contents below to let you select what you want.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;In this post&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
How I found these examples

&lt;ul&gt;
&lt;li&gt;1. Digging through my own agent history&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
Cloud, money, and store ops

&lt;ul&gt;
&lt;li&gt;2. The cloud spend report&lt;/li&gt;
&lt;li&gt;3. Publishing a game to the App Store and Google Play&lt;/li&gt;
&lt;li&gt;4. Setting up subscriptions through admin APIs&lt;/li&gt;
&lt;li&gt;5. A cost-per-user model&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
Media production

&lt;ul&gt;
&lt;li&gt;6. A marketing kit for my food tracker&lt;/li&gt;
&lt;li&gt;7. A demo video set, rendered around midnight&lt;/li&gt;
&lt;li&gt;8. A commercial from six clips and a jingle&lt;/li&gt;
&lt;li&gt;9. A band that doesn’t exist&lt;/li&gt;
&lt;li&gt;10. Recording gameplay with OBS&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
Eyes on the screen

&lt;ul&gt;
&lt;li&gt;11. An unattended UX review&lt;/li&gt;
&lt;li&gt;12. Vision-driven testing&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
The manager’s copilot

&lt;ul&gt;
&lt;li&gt;13. Launches: before, day-of, and after&lt;/li&gt;
&lt;li&gt;14. How our team’s work actually flows&lt;/li&gt;
&lt;li&gt;15. The stray K&lt;/li&gt;
&lt;li&gt;16. A kernel vulnerability, checked and patched&lt;/li&gt;
&lt;li&gt;17. Planning a team event&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
Home lab and personal IT

&lt;ul&gt;
&lt;li&gt;18. “Is something jamming my audio card?”&lt;/li&gt;
&lt;li&gt;19. A home lab, set up over SSH&lt;/li&gt;
&lt;li&gt;20. A VPN on my Raspberry Pi&lt;/li&gt;
&lt;li&gt;21. Rescuing a new inference server&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
Life

&lt;ul&gt;
&lt;li&gt;22. A road-trip playlist for my mom&lt;/li&gt;
&lt;li&gt;23. 11 years of my Spotify data&lt;/li&gt;
&lt;li&gt;24. Reading my old Facebook data&lt;/li&gt;
&lt;li&gt;25. Kitchen timers and a meal plan&lt;/li&gt;
&lt;li&gt;26. An AI phone receptionist&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;When it goes sideways&lt;/li&gt;
&lt;li&gt;Patterns that worked&lt;/li&gt;
&lt;li&gt;Try it&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  How I found these examples
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Digging through my own agent history
&lt;/h3&gt;

&lt;p&gt;To write this post, I asked Claude Code to go find the examples for me. Seven agents ran in parallel and swept 356 project folders, 6,818 of my past prompts, and the job history from FOREMAN, a tool I built to run coding agents unattended. They came back with about 80 examples.&lt;/p&gt;

&lt;p&gt;This post counts as example 1, haha! Here are the other 25 worth sharing.&lt;/p&gt;

&lt;h2&gt;
  
  
  Cloud, money, and store ops
&lt;/h2&gt;

&lt;h3&gt;
  
  
  2. The cloud spend report
&lt;/h3&gt;

&lt;p&gt;I asked for an expense report across all of my team's Google Cloud projects: what we aren't using that still costs money, what we could scale down, and what is expensive but actually used. I told it to use the gcloud CLI and to MAKE NO CHANGES. It swept every project my account could see, read-only, and wrote it up. The headline: about 59% of the spend it could identify was Cloud Run instances kept online 24/7 and sitting almost entirely idle. I then had it rewrite the report for leadership and link it from the ticket. &lt;em&gt;(NOTE: using a Read Only Service Account and env isolation is best when allowing an LLM to drive your cloud infra. We don't want boo-boos...)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fce8gq7xt5cb29hd5x080.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fce8gq7xt5cb29hd5x080.png" alt="A terminal-style card. The prompt asks for an expense report across the team's Google Cloud resources using the gcloud CLI, in capitals: MAKE NO CHANGES. The agent replies that it ran a read-only sweep, that about 59% of identified spend is idle Cloud Run instances, and that it saved the report." width="800" height="421"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Publishing a game to the App Store and Google Play
&lt;/h3&gt;

&lt;p&gt;For my game MagLava, the agent found the store credentials I had staged in Keychain, filled in the store listings in seven languages, uploaded builds to TestFlight and Google Play testing, and pushed the signing certificates into CI. It also rendered 126 localized screenshot cards, a trailer, and an App Store preview. The release notes it keeps are nice.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fythg8ufyyowfynehwuyv.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fythg8ufyyowfynehwuyv.jpg" alt="Seven App Store screenshot cards for the game MagLava, side by side, each showing the same level with its caption translated into English, German, Spanish, Japanese, Portuguese, Turkish and Chinese." width="799" height="247"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;  &lt;iframe src="https://www.youtube.com/embed/0L0MMnvFFjE" width="710" height="399"&gt;
  &lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fpejwbiruvpl7dyla681q.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fpejwbiruvpl7dyla681q.png" alt="An excerpt of the MagLava release log: the Apple build is valid and beta approved on TestFlight, Google Play open testing is configured but public availability is not confirmed, and store information is saved in all seven game languages." width="800" height="639"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Setting up subscriptions through admin APIs
&lt;/h3&gt;

&lt;p&gt;For my food tracker app, it used the RevenueCat and Google Play admin APIs to create the subscription plans: monthly and annual, with a 7-day trial. It did a dry run first, because Play base-plan IDs can never be reused once created. Along the way it noticed RevenueCat was still on sample settings, which would have made Pro silently fail.&lt;/p&gt;

&lt;h3&gt;
  
  
  5. A cost-per-user model
&lt;/h3&gt;

&lt;p&gt;For the same food tracker app, it built a cost-per-user model from real usage, noticed billing export had never been turned on, and changed one Cloud Run setting that took the idle cost from about $37 a month to about $0.05.&lt;/p&gt;

&lt;h2&gt;
  
  
  Media production
&lt;/h2&gt;

&lt;h3&gt;
  
  
  6. A marketing kit for my food tracker
&lt;/h3&gt;

&lt;p&gt;A hero video, three short clips, captions, 23 generated food photos, Play Store screenshots, and a feature graphic. The pipeline writes the narration first (Gemini text-to-speech), so every on-screen action is held exactly as long as its voice-over. Playwright drives the app at phone size, Remotion puts the footage in a phone frame, and ffmpeg mixes in a music bed. Everything is captured from a seeded demo account, so no real user data shows up anywhere. It did however use a really old TTS model, so it sounds bad.&lt;/p&gt;

&lt;p&gt;  &lt;iframe src="https://www.youtube.com/embed/6cDhXwM8-xE" width="710" height="399"&gt;
  &lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fsmsaphs45e2cr2uv2w6h.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fsmsaphs45e2cr2uv2w6h.jpg" alt="A grid of 18 of the generated food photos: avocado toast, banana pancakes, salmon and rice, chicken tacos, lentil soup, pepperoni pizza and more." width="799" height="398"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  7. A demo video set, rendered around midnight
&lt;/h3&gt;

&lt;p&gt;For FoFo Care, a Mac help app I built a while ago, the agent recorded the real packaged app, generated narration, captioned it with Whisper, composited it in Remotion, added music, and checked its own output. It even left notes on bugs it ran into while recording. OBS was installed, but it chose not to use it. It captured the app window through Chrome DevTools instead, which needs no screen recording permission and keeps desktop clutter out of the shot.&lt;/p&gt;

&lt;p&gt;  &lt;iframe src="https://www.youtube.com/embed/xgq9_-cl9as" width="710" height="399"&gt;
  &lt;/iframe&gt;
&lt;/p&gt;

&lt;h3&gt;
  
  
  8. A commercial from six clips and a jingle
&lt;/h3&gt;

&lt;p&gt;For "Robots Save The Call," it mapped the song's beat (120.96 BPM) and cut on it, generated four voiceover takes and checked each one by transcribing it back, then rendered nine versions across aspect ratios. Here is the full ad.&lt;/p&gt;

&lt;p&gt;  &lt;iframe src="https://www.youtube.com/embed/OMTMo1HDEII" width="710" height="399"&gt;
  &lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fg2kv0su005d3zxcwn359.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fg2kv0su005d3zxcwn359.jpg" alt="The same frame of the commercial in three aspect ratios side by side: a cheerful blue robot with a headset floating among colorful phones, captioned " width="800" height="235"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  9. A band that doesn’t exist
&lt;/h3&gt;

&lt;p&gt;One FOREMAN job, $3.90: a made-up band called Saltline with a persona, lyrics, four songs, cover art, and a website.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F3izwh3pvjg1ii1qvmu96.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F3izwh3pvjg1ii1qvmu96.jpg" alt="The Saltline band website: four musicians standing on a misty beach at dusk under the band name, the tagline " width="799" height="555"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A note on the music: the four tracks on that site are 30-second instrumental clips from Google's Lyria model, and honestly they are... not the best yet (getting there). The good stuff came later. Here is "Super Quick," a full song I made for the band with Suno:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://fterry.su.domains/video-files/nca-saltline-super-quick.mp3" rel="noopener noreferrer"&gt;Listen: Super Quick, a song made with Suno for the Saltline band, about 2 minutes.&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  10. Recording gameplay with OBS
&lt;/h3&gt;

&lt;p&gt;I made a StepMania song pack out of my own songs using A.I. and wanted a gameplay video for each one. I asked if it could automate it: open the game, play each song on Hard, and have OBS record. I set up the OBS scene, told it to go, and 13 videos landed about two minutes apart, each chart played by the game's AutoPlay.&lt;/p&gt;

&lt;p&gt;  &lt;iframe src="https://www.youtube.com/embed/xdkjDLASOnI" width="710" height="399"&gt;
  &lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  Eyes on the screen
&lt;/h2&gt;

&lt;h3&gt;
  
  
  11. An unattended UX review
&lt;/h3&gt;

&lt;p&gt;I told the agent I needed a general test and UX review of my app's pilot build, to work as autonomously as possible, and that OBS was set up if it wanted to record. It drove the real packaged app with Playwright over six passes and came back with a prioritized bug list, 14 annotated screenshots, and a two-minute walkthrough video. A couple of the finds I would not have caught quickly: the chat invented a fake technical reason when a tool was behind the paywall, and a confirmation dialog showed text that was written for the LLM, not the user.&lt;/p&gt;

&lt;p&gt;The OBS part: it tried OBS first. OBS pulled in desktop clutter and audio, and one of its automation calls crashed OBS outright. So it switched to recording the app window through Chrome DevTools, on its own. The same tool that worked great for gameplay was the wrong tool here, and the agent figured that out without me.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fgmezsf6ojuyrjo37h9pu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fgmezsf6ojuyrjo37h9pu.png" alt="A bug screenshot from the UX review: the chat assistant gives an invented technical reason for a failure instead of saying the tool requires an upgrade." width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F5ff6sj3stirxt4qmgtiq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F5ff6sj3stirxt4qmgtiq.png" alt="A bug screenshot from the UX review: a confirmation dialog for a destructive tool shows prompt text that was written for the LLM." width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;  &lt;iframe src="https://www.youtube.com/embed/bPm1AS60uME" width="710" height="399"&gt;
  &lt;/iframe&gt;
&lt;/p&gt;

&lt;h3&gt;
  
  
  12. Vision-driven testing
&lt;/h3&gt;

&lt;p&gt;This one has been a long time coming. I have been chasing vision-driven testing for a while: started as a screen-grid experiment with a local vision model, now an auto-tester that screenshots the screen, lets Gemini pick the next click, and handles native macOS dialogs a browser driver cannot see. The goal every time has been the same: download one of our work apps and run it to completion.&lt;/p&gt;

&lt;h2&gt;
  
  
  The manager’s copilot
&lt;/h2&gt;

&lt;h3&gt;
  
  
  13. Launches: before, day-of, and after
&lt;/h3&gt;

&lt;p&gt;I have started using agents at all three points of a launch.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Before:&lt;/strong&gt; For my food tracker, I asked "am I actually ready to launch this thing?" and had it check the marketing site, app, backend, security, payments, and deployment, then save findings to a file. My favorite part: it later corrected one of its own findings ("My original finding was wrong on the facts") after checking the actual database.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Day-of:&lt;/strong&gt; At work, the morning we rolled out a new feature, I asked it to check recent logs and tell me how it was going for folks. READ ONLY. It queried the logs and database, built an HTML report, and screenshotted it so I could share it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;After:&lt;/strong&gt; When one of my side projects hit v1, I asked it to look at all my git commits and all my Claude chats for the project and figure out how much development time went into it.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Flczb5r4fsn5lvuzvg8um.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Flczb5r4fsn5lvuzvg8um.png" alt="The top of the FoFo Food Tracker launch readiness audit, written by Claude: a P0 remediation table listing items like " width="800" height="600"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fyeirezhja82wyr0yvhgc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fyeirezhja82wyr0yvhgc.png" alt="A terminal-style card. The prompt says a feature just rolled out and asks for a read-only check of recent logs. The agent replies that it queried Cloud Logging and Firestore, covered adoption, latency and errors, and built an HTML launch report with a screenshot to share." width="799" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  14. How our team’s work actually flows
&lt;/h3&gt;

&lt;p&gt;I asked it to use six months of git and Jira history to answer three questions: how long does it take us to get work done, how much carries over from sprint to sprint, and is our pace sustainable? It built an HTML report. I cannot show the real one, so the chart below uses made-up numbers for what most teams see: most of a ticket's life is spent waiting, not being worked on.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fmn4lsn7pnqkq6j63by5w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fmn4lsn7pnqkq6j63by5w.png" alt="An illustrative stacked bar chart with made-up numbers titled " width="800" height="513"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  15. The stray K
&lt;/h3&gt;

&lt;p&gt;We started getting alerts that users were having issues. On day one, the agent traced it to a vendor service being down. On day two, the same alerts came back. I asked it to check if the vendor endpoint was up, without posting to it or authenticating. It was healthy. So it pulled the deployed source from the storage bucket and found a single stray &lt;code&gt;K&lt;/code&gt; character in one file. That threw an error inside a success handler, the error handler swallowed it and reported failure, and the vendor call had actually succeeded the whole time. It was live for about 12 minutes. I had it write up the incident for our lead developer.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fxeh7gm2byampexehxn92.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fxeh7gm2byampexehxn92.png" alt="A terminal-style card with names stripped. The prompts ask the agent to check whether the vendor endpoint is up without posting or authenticating, then why the error alerts keep firing. The agent replies the endpoint was healthy, a stray K in the deployed copy of one file threw inside a then handler that the catch swallowed, and the vendor call had actually succeeded." width="800" height="546"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  16. A kernel vulnerability, checked and patched
&lt;/h3&gt;

&lt;p&gt;When a Linux kernel vulnerability was announced, I asked if it affected any of our stuff, read-only. It checked across our projects, identified already patched VMs over SSH one at a time, and wrote a Slack summary I could send my boss.&lt;/p&gt;

&lt;h3&gt;
  
  
  17. Planning a team event
&lt;/h3&gt;

&lt;p&gt;My agent also helped plan our team event: a participant journey, an agenda, a dry run against a fake team, and a live site.&lt;/p&gt;

&lt;h2&gt;
  
  
  Home lab and personal IT
&lt;/h2&gt;

&lt;h3&gt;
  
  
  18. “Is something jamming my audio card?”
&lt;/h3&gt;

&lt;p&gt;My Mac would start playing audio and then immediately stop. I asked the agent in the middle of a video project. It checked audio processes, virtual audio drivers, and system logs, and found the real problem: my JBL headset was stuck in hands-free mode, the 16 kHz mono mode meant for calls, instead of stereo playback. Nothing to do with code at all. So turned off headphones and things worked again!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fvplnr5j6z0ahvc5vu5s5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fvplnr5j6z0ahvc5vu5s5.png" alt="A terminal-style card. The prompt asks whether something is jamming the Mac's audio card. The agent replies that the JBL headset is stuck in hands-free mode, showing system output with an input sample rate of 16000 marked " width="800" height="559"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  19. A home lab, set up over SSH
&lt;/h3&gt;

&lt;p&gt;I have four machines at home for running local models. Agents did the setup over SSH: firewall rules, a scheduled task to keep WSL running on the Windows box, text-to-speech, speech recognition, and local model servers, a LiteLLM proxy, SearXNG search, and Langfuse tracing. Every service has a check script it can rerun. Now all of it is saved as a skill, so any future session already knows the boxes and the traps we have already hit.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fqmf83r9pod10ep5l2scs.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fqmf83r9pod10ep5l2scs.png" alt="A diagram of the home lab. Claude on the Mac reaches four machines over SSH: HULK runs shared services like LiteLLM, SearXNG, Langfuse and Firecrawl; HERMES runs a personal agent with calendar and Spotify connections; INFINITY runs a local reasoning model; WARLOCK runs voice services under Windows and WSL2." width="800" height="636"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  20. A VPN on my Raspberry Pi
&lt;/h3&gt;

&lt;p&gt;My agent set up a VPN on my Raspberry Pi with an auto-rollback timer, so if the VPN cut off SSH, the change would undo itself.&lt;/p&gt;

&lt;h3&gt;
  
  
  21. Rescuing a new inference server
&lt;/h3&gt;

&lt;p&gt;At work, a brand new server came up with a (too) bare-minimum install (no sudo, no DNS). The agent got the machine working over SSH.&lt;/p&gt;

&lt;h2&gt;
  
  
  Life
&lt;/h2&gt;

&lt;h3&gt;
  
  
  22. A road-trip playlist for my mom
&lt;/h3&gt;

&lt;p&gt;I was going to San Francisco with my mom (likes 70s, R&amp;amp;B, soul) and my brothers (video game music, electronic). I asked for a playlist called "SanFranTripping," at least 30 tracks, with a good mix of what we all like, saved straight to my Spotify. It used my listening history and my Spotify connection and came back with 60 songs. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fqf9sxin4761p5stkoqck.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fqf9sxin4761p5stkoqck.jpg" alt="The SanFranTripping playlist on Spotify: 60 songs, about 4 hours 15 minutes, described as an SF road trip blend for the fam, starting with September by Earth, Wind &amp;amp; Fire, A-Punk by Vampire Weekend, and Lose Yourself to Dance by Daft Punk." width="799" height="647"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  23. 11 years of my Spotify data
&lt;/h3&gt;

&lt;p&gt;I requested my full streaming history from Spotify and had an agent turn it into a single-page HTML report: 11 years, 394,588 streams, 17,332 hours. It was research for FoFo Radio, an AI radio station idea, so the agent went well past totals.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fzozs9k5r6s8q8r9uvlhy.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fzozs9k5r6s8q8r9uvlhy.jpg" alt="The top of a dark-themed Spotify listening report called FoFo Radio: 394,588 total streams, 17,332 hours listened, 8,577 unique artists, and a timeline of monthly streams from 2015 to 2026." width="800" height="572"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It ranked my top artists and tracks. "Pogo" by Digitalism wins by a mile, with 1,289 plays.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F70eb5wb0ztntxznco333.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F70eb5wb0ztntxznco333.jpg" alt="The Top Artists section of the report: The National leads with 9,286 plays, followed by Modest Mouse at 7,070, Death Cab for Cutie at 5,072, then STRFKR, Brand New, Tegan and Sara, Santigold and Daft Punk." width="800" height="614"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F8rz3q0p8v2tnag6c8boi.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F8rz3q0p8v2tnag6c8boi.jpg" alt="The Top Tracks section of the report: Pogo by Digitalism leads with 1,289 plays, far ahead of A-Punk by Vampire Weekend at 824, Disparate Youth by Santigold at 756, and Hot Thoughts by Spoon at 753." width="800" height="590"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It split out the songs I never skip, which it labeled as "A-list" rotation candidates for the station, from the ones I bail on within seconds.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F0jfemyps3rxilbu2k74h.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F0jfemyps3rxilbu2k74h.jpg" alt="The skip analysis section: a table of never-skipped tracks such as Afraid Of Everyone by The National with 602 plays, labeled A-list candidates, next to a table of the most skipped tracks with skip rates up to 90 percent." width="800" height="553"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And it found my longest "listening sessions," using a rule of no more than 10 minutes between tracks. The top one ran 47 hours and 741 tracks.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fikyr1qfqt64wm96vtwn6.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fikyr1qfqt64wm96vtwn6.jpg" alt="The Marathon Listening Sessions table: the longest session started September 8, 2022, ran 47.74 hours across 741 tracks with Modest Mouse as the top artist, followed by a 45-hour session led by Kanye West." width="800" height="518"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  24. Reading my old Facebook data
&lt;/h3&gt;

&lt;p&gt;I also exported my Facebook data and asked an agent to write about me from it, to "learn about myself from back in the day… the good moments, the sad moments." That one was a trip.&lt;/p&gt;

&lt;h3&gt;
  
  
  25. Kitchen timers and a meal plan
&lt;/h3&gt;

&lt;p&gt;My self-hosted assistant, Hermes, has set a cookie timer and a muffin reminder, and made me a meal-prep plan in Google Sheets.&lt;/p&gt;

&lt;h3&gt;
  
  
  26. An AI phone receptionist
&lt;/h3&gt;

&lt;p&gt;For an AI phone receptionist I set up, the agent configured Twilio, my router, and DNS. The receptionist answered my test call with "let me transfer you." My response: TRANSFER ME TO WHO????&lt;/p&gt;

&lt;h2&gt;
  
  
  When it goes sideways
&lt;/h2&gt;

&lt;p&gt;It is not all smooth. A few of my favorite misses:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;An agent running my art shop created about 800 Etsy draft listings I did not want.&lt;/li&gt;
&lt;li&gt;I found out my assistant could reach my Mac directly casually via conversation: "you are not sandboxed??"&lt;/li&gt;
&lt;li&gt;Deploying this blog, the agent would not listen to my upload instructions: "STOP IGNORING MY DIRECTIONS."&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Patterns that worked
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Say READ ONLY or MAKE NO CHANGES in the prompt. Scoped API Keys!!!&lt;/strong&gt; Most of the examples above started this way.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Dry run first&lt;/strong&gt; for anything that writes, creates, or can't be undone.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Auto-rollback timers&lt;/strong&gt; for network changes, so a mistake can undo itself.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Disable, don't delete.&lt;/strong&gt; You can turn something back on. You can't un-delete it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Stage credentials in Keychain&lt;/strong&gt; so you are not pasting secrets into the chat or storing in plaintext on disk.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Take a snapshot before admin changes&lt;/strong&gt;, so you can restore.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;More on this in &lt;a href="https://fterry.su.domains/posts/checking-ai-work-is-hard" rel="noopener noreferrer"&gt;Checking A.I. Work is Hard&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Try it
&lt;/h2&gt;

&lt;p&gt;There is a lot you can do with an a.i. coding agent. In these examples, I typically used Claude Code via Max subscription -- but a lot of other setups work too.&lt;/p&gt;

&lt;p&gt;Next time you wanna get a big task done, if you know the steps and can provide the APIs, see if A.I. can do it!&lt;/p&gt;

</description>
      <category>ai</category>
      <category>agents</category>
      <category>productivity</category>
      <category>operations</category>
    </item>
    <item>
      <title>Checking A.I. Work is Hard: How I Handle It</title>
      <dc:creator>Forrester Terry</dc:creator>
      <pubDate>Wed, 09 Sep 2026 17:18:52 +0000</pubDate>
      <link>https://dev.to/sweetpapa/checking-ai-work-is-hard-how-i-handle-it-1hdh</link>
      <guid>https://dev.to/sweetpapa/checking-ai-work-is-hard-how-i-handle-it-1hdh</guid>
      <description>&lt;p&gt;You spent a few good cycles, did some troubleshooting, and finally, it works!&lt;/p&gt;

&lt;p&gt;With A.I., "working" does not always mean "ready to go" though. Something can work but have:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Security issues&lt;/li&gt;
&lt;li&gt;Resource and cost issues&lt;/li&gt;
&lt;li&gt;Usability issues&lt;/li&gt;
&lt;li&gt;Incomplete features&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ffysd5k1zl3dz1g9syrxq.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ffysd5k1zl3dz1g9syrxq.jpg" alt="Futurama Fry squinting suspiciously. Top caption: " width="577" height="433"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We are making way more code than we can reasonably review.&lt;/p&gt;

&lt;p&gt;The takeaway is not that you should read harder. You cannot read your way out of this. The takeaway is that you have to move the checking somewhere it fits.&lt;/p&gt;

&lt;h2&gt;
  
  
  So what should we do to handle this?
&lt;/h2&gt;

&lt;p&gt;Whether you are shipping code, a spreadsheet, a policy draft, or a slide deck the A.I. built for you, here are some things to try.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Check the plan first, not the output.&lt;/strong&gt; The plan might be forty lines or so, compared to output that is three thousand. Before you prompt for what you want to build, ask for the approach first: read that carefully, approve it, and then let it build. Ask it to do some research before starting.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Define what "wrong" would look like before you start.&lt;/strong&gt; Try writing out: "X is wrong if Y does not match Z." Then try reviewing the work afterwards against this list.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Ask it what it changed that you did not ask for.&lt;/strong&gt; "List every change you made that was not required by what I asked. For each one, say why." A.I. tools quietly improve things. Renamed a field. Moved a file. Swapped a library. Individually reasonable, collectively how you end up somewhere you never chose.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Focus on consequence, not size.&lt;/strong&gt; Careful not to spend too much time reading every change and line. For critical functionality, read more closely. For other things, read at a high level.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5. Do a security pass.&lt;/strong&gt; Once the A.I. claims to be done, tell it to check the work it did for any security issues or gaps. I have seen the A.I. forget to implement authentication and basic security from time to time, especially while working on bigger tasks and prompts.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;6. Ask the A.I. to explain what it did.&lt;/strong&gt; Sometimes I ask my agent to give me a summary of what it did and why. You can also ask it to explain how to manually test components or chat through any questions you have.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fqdcpfg9cibzr1yp9yynx.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fqdcpfg9cibzr1yp9yynx.jpg" alt="The two-buttons meme. A sweating man reaches for two buttons labelled " width="500" height="757"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  A few bonus ones for developers
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Commit often, not once per session.&lt;/strong&gt; Be sure to do commits per milestone or feature. This makes things way easier to review ultimately, since you get smaller chunks of code changes.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Review the test, then lock it in.&lt;/strong&gt; Have the A.I. write the test from the requirement before it writes the code. Then review the tests to ensure they evaluate what you need. From there, you can use these tests as your bar for the coder. Do not let the coder adjust the tests once locked in, this is key.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Some things are best for humans.&lt;/strong&gt; If the risks are high, you should double check the work yourself. Do not let the automation handle critical actions like deletes or live data manipulation without supervision and review.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Commit before you start.&lt;/strong&gt; Otherwise, you risk the coding agent wiping out your uncommitted changes. I had this happen to me once, so it is worth throwing out there.&lt;/p&gt;

&lt;h2&gt;
  
  
  You own it
&lt;/h2&gt;

&lt;p&gt;Though we can move faster than ever, we need to make sure our workflows and processes for quality keep up.&lt;/p&gt;

&lt;p&gt;By creating a process, and having some checks before and after you start, you can keep up with the new pace at which everyone is moving.&lt;/p&gt;

&lt;h2&gt;
  
  
  Example prompts
&lt;/h2&gt;

&lt;p&gt;These are ones I have used, cleaned up so you can paste them as is.&lt;/p&gt;

&lt;h3&gt;
  
  
  Before you start
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Get a plan you can read instead of output you cannot.&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;I have outlined the requirements and specs for this project in &amp;lt;FILE&amp;gt;.
Before we write any code, do the relevant research and read the whole
requirements file, then write a detailed design document that will guide
the implementation. Save it as design.plan.md in the docs/ directory.
I will review it before we start building.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Make every requirement fail-able.&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Rewrite these requirements so each one has a stable ID (REQ-001, REQ-002)
and an "Acceptance:" line describing exactly what must be true for it to
count as done. If a requirement cannot be given a checkable acceptance
criterion, flag it instead of guessing.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Anything it flags is something you had not actually decided yet.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Confirm you have a clean starting point.&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Before we begin, confirm the working tree is clean and everything is
committed. If it is not, stop and tell me what is uncommitted.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Guardrails to paste in every time
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Stop it from acting before you have answered.&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;DO NOT MAKE CHANGES WITHOUT ASKING. First investigate and answer my
question. Do not touch the code until I say go.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Stop it from quietly editing the plan.&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Do not change the scope of our work in PROGRESS.md. If work remains, we
handle it later. Never delete tasks.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Make the dry run mandatory for anything that touches real data.&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Default to read-only. Before any action that writes, deletes, or changes
live data, show me the full plan of what you are about to do and wait for
me to say go. One plan at a time, no chaining. If any part of it cannot be
undone, say so explicitly at the top.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  After it says it is done
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Find out what it changed on its own.&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;List every change you made that was not required by what I asked.
For each one, say why you made it.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Run a security pass and send it somewhere you will actually read it.&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Review this application and make sure it is secure, both when run as a
normal user and as an administrator. Include code snippets and links to
the relevant code so I can review each finding myself. Put everything in
an MD document in the docs folder rather than answering here.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Shorter version for a smaller project:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Do a security review of this entire app and repo. Identify anything that
needs to be addressed before it goes live.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Writing findings to a file instead of the chat window is a nice trick. When the chat is gone, the file is still there tomorrow.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Ask how to check it yourself.&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;How do I test this myself? Write a short guide covering how to manually
verify each piece, including anything I need to set up first.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Asking for testing instructions hands you something you can go check independent of the a.i. coder&lt;/p&gt;

&lt;h3&gt;
  
  
  For developers
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Lock the tests before any code exists.&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Write the tests from the spec first, before any implementation exists.
Once I approve them, they are locked: you write code to pass those tests
and you do not modify or weaken them. If you believe a test is wrong,
stop and tell me. That is a conversation, not an edit.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>ai</category>
      <category>developers</category>
      <category>security</category>
      <category>automation</category>
    </item>
    <item>
      <title>A.I. Made It… But Can You Explain It?</title>
      <dc:creator>Forrester Terry</dc:creator>
      <pubDate>Tue, 01 Sep 2026 15:50:01 +0000</pubDate>
      <link>https://dev.to/sweetpapa/ai-made-it-but-can-you-explain-it-bo2</link>
      <guid>https://dev.to/sweetpapa/ai-made-it-but-can-you-explain-it-bo2</guid>
      <description>&lt;p&gt;Imagine: You are in a meeting with a vendor. It is going fine. Then they ask a completely normal question:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;"So, how exactly does X work?"&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;And you stall. Not because it is a hard question. Because you shipped X, you own X, and you did not actually write X. Your A.I. did, and you skimmed it, and it worked, and you moved on.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fr7en02oztr8gtvv9t5je.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fr7en02oztr8gtvv9t5je.jpeg" alt="Two-panel comic. Panel one: a vendor in a meeting asks " width="800" height="447"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I had this happen to me. It was no big deal, I explained myself and found the answer, but I did not like the feeling of not knowing.&lt;/p&gt;

&lt;h2&gt;
  
  
  The worry is real, and it is not new
&lt;/h2&gt;

&lt;p&gt;One of the big fears about A.I. is what it does to how much we learn, and how well.&lt;/p&gt;

&lt;p&gt;We are already leaning on it hard. People get their news explained to them. Kids get their homework answered. We get our custom software written. These are genuinely great use cases.&lt;/p&gt;

&lt;p&gt;The problems start when:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;We read the A.I. summary and never look at the actual source.&lt;/li&gt;
&lt;li&gt;We get the answer instead of doing the work, so we never actually learn much.&lt;/li&gt;
&lt;li&gt;We accept the code without understanding it, and then something breaks and we have no idea where to even start looking.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For a developer or IT professional, the bill comes due in three ways. You learn less about how your own system works. Your troubleshooting gets slower and shallower. And your codebase quietly turns into a liability, because you are responsible for something you cannot explain.&lt;/p&gt;

&lt;p&gt;None of that shows up on day one.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Manager Parallel
&lt;/h2&gt;

&lt;p&gt;I have kinda lived a version of this transition, and so has every manager reading this.&lt;/p&gt;

&lt;p&gt;When you move from writing code all day to managing people who write code all day, you produce less. Way less. And you do lose a little of your edge. That is real.&lt;/p&gt;

&lt;p&gt;But something else happens. You start exercising different skills, and they turn out to matter a lot: reading a system at the architecture level, asking the question that unblocks somebody, knowing which risk is actually the risk. You stop being the person who types the most and you become the person who understands more.&lt;/p&gt;

&lt;p&gt;And honestly, your "old" skills become a foundation for those new skills. For non-technical folks, your expertise in your domain becomes incredibly useful for directing the output and checking the quality.&lt;/p&gt;

&lt;p&gt;So the goal is not "use less A.I." The goal is to make sure the thing you traded away is the typing, and not the understanding and awareness.&lt;/p&gt;

&lt;h2&gt;
  
  
  How I Avoid This Issue
&lt;/h2&gt;

&lt;p&gt;I let A.I. do nearly all of my coding, and I have not felt myself getting dull. Here is what that actually looks like for me:&lt;/p&gt;

&lt;h3&gt;
  
  
  General Tips
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Make it explain itself, on purpose.&lt;/strong&gt; I ask a lot of "why" out loud. Some prompts I use constantly:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;"Explain this like I have to defend it in a design review tomorrow."&lt;/li&gt;
&lt;li&gt;"What approaches did you consider and reject here, and why?"&lt;/li&gt;
&lt;li&gt;"What is the riskiest part of this change?"&lt;/li&gt;
&lt;li&gt;"What would break if traffic went up 10x?"&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Any of those will teach you something or even catch real problems.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Stop on the words you do not know.&lt;/strong&gt; A term goes by that you cannot define: so stop and ask, or go look it up. Small but fundamental and very powerful.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Recite it back before you ship it.&lt;/strong&gt; For anything meaningful, I close my agent and try to explain the change or work to myself in my head. If I cannot get through it cleanly, I should review the work and plan again.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Keep building things that challenge you.&lt;/strong&gt; Do it on your own time or as time allows, on something you actually care about. Run into the wall, get stuck, try again. Nobody is watching, there is no deadline, and it is still a quick way to learn anything.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Watch how other people use theirs.&lt;/strong&gt; Everyone has worked out some workflow trick. Ask them.&lt;/p&gt;

&lt;h3&gt;
  
  
  Tips Particularly For Developers
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Read the logs yourself, especially when the agent is circling.&lt;/strong&gt; Let the A.I. read them first, absolutely. But the moment your agent takes its third swing at the same bug, that is your cue to open the logs personally. Nine times out of ten there is a line in there that it skipped right past, and you spotting it is what breaks the loop.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Use the design phase as your learning budget.&lt;/strong&gt; Before anything gets built, I will have it lay out two or three approaches with real tradeoffs, and tell me who else does it that way. That is the requirements and design part of the SDLC. This is where most of my exposure to new frameworks and patterns comes from now.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Read the diff instead of the file.&lt;/strong&gt; Telling yourself you will "skim the whole file later" can end up a daunting task. Reading the diff is easier and it is the difference between approving code and reading code. If something looks weird in there, stop and ask the bot about it before it merges.&lt;/p&gt;

&lt;h2&gt;
  
  
  So…
&lt;/h2&gt;

&lt;p&gt;Like I said, I let A.I. write most of my code. But my role remains involved, I am just not doing the actual writing anymore. I'm still testing, still designing, still exploring and asking questions.&lt;/p&gt;

&lt;p&gt;Next time you finish something, try asking this to yourself.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;"If someone stopped you in a meeting and asked how it works, could you tell them?"&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Not line by line. Just the shape of it, out loud, without opening your laptop or asking your agent.&lt;/p&gt;

&lt;p&gt;If yes, you are fine. Go faster, fam!&lt;/p&gt;

&lt;p&gt;If not, there is likely something new for you to learn.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>developers</category>
      <category>learning</category>
    </item>
    <item>
      <title>Product Shipped! But Now What? The Part I Forgot About.</title>
      <dc:creator>Forrester Terry</dc:creator>
      <pubDate>Wed, 15 Apr 2026 08:03:00 +0000</pubDate>
      <link>https://dev.to/sweetpapa/product-shipped-but-now-what-the-part-i-forgot-about-45dg</link>
      <guid>https://dev.to/sweetpapa/product-shipped-but-now-what-the-part-i-forgot-about-45dg</guid>
      <description>&lt;p&gt;As a developer, I love to build.&lt;/p&gt;

&lt;p&gt;Planning it out, picking the stack, getting into flow state, watching something go from nothing to a working product. &lt;/p&gt;

&lt;p&gt;That part is fun. And with AI tools in the mix, that part is faster than ever.&lt;/p&gt;

&lt;p&gt;But here's what I've been facing in reality: &lt;strong&gt;shipping the code is maybe 30% of the work.&lt;/strong&gt; The other 70% is everything that comes after. &lt;/p&gt;

&lt;p&gt;I want to walk through what that looked like in practice for my recent project. Not quite a tutorial or success story. Just an honest look at the messy middle.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Build
&lt;/h2&gt;

&lt;p&gt;A few months ago I built &lt;a href="https://clip.fofo.dev" rel="noopener noreferrer"&gt;FoFoClip&lt;/a&gt;, a tool that takes a podcast episode and turns it into polished, ready-to-post video clips. You upload your audio, pick a style, and get clips delivered to your inbox. Supports 6+ languages.&lt;/p&gt;

&lt;p&gt;The tech stack is my usual go-to: Vue 3, Quasar Framework, Firebase (Hosting, Auth, Cloud Functions, Storage, Tasks), with AI handling the heavy lifting on the backend for transcription, clip selection, and caption rendering.&lt;/p&gt;

&lt;p&gt;I used AI pair programming for the entire build. Claude for architecture decisions and complex logic, Claude Code for fast iteration, and a workflow where I'd break things into focused prompts rather than trying to generate everything at once. If you've read my earlier posts, you know I'm a big believer in this approach.&lt;/p&gt;

&lt;p&gt;The build took about a solid week of evening work. Prompting, testing, revising, prompting again. Security reviews. Edge case handling. Making sure the clip styles actually looked good across different types of content.&lt;/p&gt;

&lt;p&gt;And then it was done and deployed! Real product offering, real Stripe integration, real pricing.&lt;/p&gt;

&lt;p&gt;I felt great. I had built something real. Until haha...&lt;/p&gt;

&lt;h2&gt;
  
  
  The Silence
&lt;/h2&gt;

&lt;p&gt;Here's the thing about launching a product as a solo developer: unless you built some hype or awareness... nobody is waiting for it.&lt;/p&gt;

&lt;p&gt;There's no Product Hunt launch with 500 upvotes. No Twitter thread going viral, etc. I push to production, maybe tell a few people, and then... quiet.&lt;/p&gt;

&lt;p&gt;I told my mom. I posted a bit on social media. And then I kind of waited for something to happen.&lt;/p&gt;

&lt;p&gt;Nothing happened.&lt;/p&gt;

&lt;p&gt;So I did what a lot of us do when things aren't moving. I went and worked on other projects. I had plenty of them. It felt productive. It felt like I was still shipping. But really, I was avoiding the harder work that FoFoClip needed.&lt;/p&gt;

&lt;h2&gt;
  
  
  The YouTube Ads Experiment
&lt;/h2&gt;

&lt;p&gt;Eventually I came back to FoFoClip and decided to throw some money at it. I made a 30-second video ad, set up a YouTube campaign targeting podcast-related search terms, and put $50 behind it.&lt;/p&gt;

&lt;p&gt;The results: 59 website visits. Zero conversions.&lt;/p&gt;

&lt;p&gt;While I was proud some people were clicking (though honestly, they may have been ghost clicks...) not one person signed up. Not one person bought a DANG THING.&lt;/p&gt;

&lt;p&gt;Now, $50 on YouTube ads is barely a test... but zero conversions out of 59 visits still stings. It made me look harder at the landing page, the messaging, the trust signals, all the stuff that has nothing to do with code quality.&lt;/p&gt;

&lt;p&gt;A couple things I found:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Perhaps the pricing was too high?&lt;/li&gt;
&lt;li&gt;Perhaps the brand was confusing. The product is "fofoclip," the domain is clip.fofo.dev, support emails come from sweetpapatechnologies.com. That's a lot of "who are these people?"&lt;/li&gt;
&lt;li&gt;I had no analytics that actually worked. My cookie consent banner was so privacy-friendly that most visitors opted out and never got tracked. I literally could not see my own traffic.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;None of this is a code problem. This was even bigger. It was a marketing problem!&lt;/p&gt;

&lt;h2&gt;
  
  
  Google Won't Index My Site
&lt;/h2&gt;

&lt;p&gt;After the ads experiment, I noticed that searching for my site on Google returned nothing. I assumed it was a technical issue. Spent time making sure everything was statically rendered at build time. Checked my robots.txt. Checked my HTTP headers. Checked for noindex meta tags. Everything was clean.&lt;/p&gt;

&lt;p&gt;Then I looked at Google Search Console and saw this status:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;"Crawled - currently not indexed"&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;So... basically Google successfully crawled my site. It confirmed that indexing was allowed. It fetched the page without errors. And then it chose NOT to index it.&lt;/p&gt;

&lt;p&gt;The reason likely: trust. My site has zero backlinks. No referring pages. No external mentions anywhere on the internet. Google looked at clip.fofo.dev and essentially said: "We see you. We just don't have a reason to care yet."&lt;/p&gt;

&lt;p&gt;This was a humbling realization, because I have never had that happen before... You can have perfect headers, perfect SSG, perfect robots.txt, and Google will still shrug if you haven't done the non-technical work of building credibility on the web.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I'm Learning
&lt;/h2&gt;

&lt;p&gt;I don't have a framework for this or big tips. I'm still in the middle of it and still learning. But here's what's becoming clear:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Building can become the comfort zone.&lt;/strong&gt; Developers default to solving problems with code because that's what we know. But sometimes the issue is much more about UX and non-architectural &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Marketing is a skill, not a chore.&lt;/strong&gt; I used to think of marketing as something you tack on after the real work is done. It's not, it is very much a big and standalone thing. Understanding why someone would trust a new product enough to pay for it, that's a design problem just as interesting as any architecture decision.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The build never really ends, but it needs to share bandwidth.&lt;/strong&gt; I still have bugs to fix and features to add. But if I spend all my energy on code and none on outreach, content, and trust-building, I'll have a really well-engineered product that nobody uses.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Talk about what you're building.&lt;/strong&gt; This is something I'm getting better at. Blog posts, Bluesky updates, dev.to articles. Every piece of content you put out there is a signal to both humans and search engines that you exist. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A.I. is super helpful for beyond just coding.&lt;/strong&gt; I was able to make ad content, promotional material, and get all sorts of questions I had about marketing answered.&lt;/p&gt;

&lt;p&gt;For a bootstrapped solo project, content might be the most cost-effective marketing channel there is.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where I'm At Now
&lt;/h2&gt;

&lt;p&gt;FoFoClip is still live at &lt;a href="https://clip.fofo.dev" rel="noopener noreferrer"&gt;clip.fofo.dev&lt;/a&gt;. I'm still working on it.&lt;/p&gt;

&lt;p&gt;I also have a bunch of other SPT projects in various stages. The temptation to go heads-down on those is real. But I know from experience that building another thing won't solve the problem that this thing has.&lt;/p&gt;

&lt;p&gt;The code was the easy part. Of course there were challenges and headaches along the way, but getting people to find my service, trust it, and pay for it... that's the actual product work. And I'm just getting started on it.&lt;/p&gt;

&lt;p&gt;It will be interesting to see if this app and service gets any use, and serves a purpose for someone. &lt;/p&gt;

&lt;p&gt;That is what makes coding fun, is seeing the product come to life.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>ai</category>
      <category>beginners</category>
      <category>product</category>
    </item>
    <item>
      <title>Your AI Coder Will Go Rogue If You Let It (Here's Some Tips to Stay in Control)</title>
      <dc:creator>Forrester Terry</dc:creator>
      <pubDate>Thu, 22 Jan 2026 05:37:04 +0000</pubDate>
      <link>https://dev.to/sweetpapa/your-ai-coder-will-go-rogue-if-you-let-it-heres-some-tips-to-stay-in-control-10pn</link>
      <guid>https://dev.to/sweetpapa/your-ai-coder-will-go-rogue-if-you-let-it-heres-some-tips-to-stay-in-control-10pn</guid>
      <description>&lt;h1&gt;
  
  
  Lessons from Building with AI Coding Assistants
&lt;/h1&gt;

&lt;p&gt;So I've been building a lot of stuff with AI coding assistants lately—like, a &lt;em&gt;lot&lt;/em&gt;. And one thing I keep running into is this: the AI will just... make decisions for you if you're not paying attention. Sometimes good ones! But sometimes it'll confidently march you right off a cliff.&lt;/p&gt;

&lt;p&gt;This isn't me hating on AI coding. I'm fully bought in at this point. But there's a difference between &lt;em&gt;using&lt;/em&gt; an AI coder and actually &lt;em&gt;directing&lt;/em&gt; one.&lt;/p&gt;

&lt;p&gt;Here's some stuff I've learned that might save you some headaches.&lt;/p&gt;




&lt;h2&gt;
  
  
  Challenge It When It Changes Your Approach
&lt;/h2&gt;

&lt;p&gt;AI coders have opinions. They'll make architecture decisions without asking you first, and if you're not watching closely, you might not even notice until way later.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Websocket Ambush
&lt;/h3&gt;

&lt;p&gt;I was building something using pipes—a deliberate choice for my use case. Somewhere mid-conversation, the AI just... switched to websockets. No "hey, should we consider this?" No discussion at all. It just started writing websocket code like we'd agreed on it.&lt;/p&gt;

&lt;p&gt;We hadn't agreed on anything.&lt;/p&gt;

&lt;p&gt;I had to stop and say "no, go back, I want pipes for this." And it did! Immediately! But if I hadn't caught it, I would've ended up with an architecture I didn't want.&lt;/p&gt;

&lt;h3&gt;
  
  
  The "Write Scripts to Disk" Thing
&lt;/h3&gt;

&lt;p&gt;Same project, different issue. The AI started writing executable scripts to disk as part of its solution. Technically functional? Sure. A good idea in most production environments? Absolutely not—that's a security red flag in a lot of contexts.&lt;/p&gt;

&lt;p&gt;I had to explicitly ban that approach before it became a problem.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The pattern:&lt;/strong&gt; AI optimizes for "does it work." You have to optimize for "is this appropriate for my situation"—security, compliance, maintainability, all that stuff that AI doesn't naturally think about.&lt;/p&gt;




&lt;h2&gt;
  
  
  Tell It to Do Its Own Testing
&lt;/h2&gt;

&lt;p&gt;This one saves me a bit of time: &lt;strong&gt;make the AI test its own code before giving it to you.&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  The Bad Command Loop
&lt;/h3&gt;

&lt;p&gt;I kept getting commands and code that would fail. Copy, paste, error. Copy, paste, different error. Over and over. Basically the AI was using me as its test runner.&lt;/p&gt;

&lt;p&gt;Then it clicked—the AI can execute commands itself. It can iterate on its own. It can figure out what actually works before handing me something.&lt;/p&gt;

&lt;p&gt;So I told it: "Test this yourself first. Iterate until it works, then show me the solution."&lt;/p&gt;

&lt;p&gt;It actually worked!&lt;/p&gt;

&lt;p&gt;It ran through several failed attempts on its own, found something that actually worked, and gave me that. All that debugging time I would've spent? Gone. The AI did it for me.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The takeaway:&lt;/strong&gt; If you're testing code that keeps failing, ask yourself—could the AI have tested this itself? If yes, just tell it to do that. You're the architect, not the test runner.&lt;/p&gt;




&lt;h2&gt;
  
  
  Sometimes You Need Research, Not Code
&lt;/h2&gt;

&lt;p&gt;Sometimes the AI is stumbling because it doesn't have enough context. It's trying things, hitting walls, trying more things—and you're both stuck.&lt;/p&gt;

&lt;h3&gt;
  
  
  Using Another AI to Unblock the First One
&lt;/h3&gt;

&lt;p&gt;I had my AI coder grinding through a problem, throwing idea after idea at it. Nothing was sticking. We were both frustrated (yes, I personify it, don't judge me haha).&lt;/p&gt;

&lt;p&gt;Here's what I ended up doing: I opened a separate chat with Gemini Pro—not to write code, but just to talk through approaches. "Hey, I'm trying to do X. What are the proper patterns for this? What should I be thinking about?"&lt;/p&gt;

&lt;p&gt;Gemini did research from the web and gave me a solid breakdown of the right approach. I took that conversation and fed it to my AI coder.&lt;/p&gt;

&lt;p&gt;Instant clarity. It stopped flailing and just... did the thing.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why this works:&lt;/strong&gt; Your coding AI is optimized for implementation. Sometimes you need a "thinking" conversation before you can have a "building" conversation. Just like having your requirements figured out before you start designing or building.&lt;/p&gt;

&lt;p&gt;If you have access to Deep Research tools, those work great for this. Let the research tool go deep on the problem, then bring those findings back to your coder.&lt;/p&gt;




&lt;h2&gt;
  
  
  AI-Generated Deployment Scripts (Carefully!)
&lt;/h2&gt;

&lt;p&gt;Okay, this one needs a big warning label, but it's too useful not to mention.&lt;/p&gt;

&lt;p&gt;You can have your AI write helper scripts for cloud CLI commands—deployments, configuration, infrastructure setup. This saves a ton of time. &lt;strong&gt;But you absolutely have to review everything before running it.&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Terraform Became My Friend
&lt;/h3&gt;

&lt;p&gt;I needed to set up a backend app—VM or Cloud Run, SSL certs, static IPs, load balancer stuff. Lots of moving pieces.&lt;/p&gt;

&lt;p&gt;I used Deep Research first to figure out the best approach. What's the right pattern? What services do I need? What order should things happen?&lt;/p&gt;

&lt;p&gt;Then I had the AI generate a Terraform script based on that research. The script pre-checked dependencies, let me input my variables cleanly, created everything in the right order, and actually worked on the first run.&lt;/p&gt;

&lt;p&gt;Honestly, this whole experience made me fall in love with Terraform. AI generating infrastructure-as-code plus Terraform's built-in safety features (&lt;code&gt;plan&lt;/code&gt; before &lt;code&gt;apply&lt;/code&gt;) is a really nice combo.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Giant Caveat
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;ALWAYS ALWAYS review deployment scripts before running them.&lt;/strong&gt; Check for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Destructive actions (&lt;code&gt;destroy&lt;/code&gt;, &lt;code&gt;delete&lt;/code&gt;, &lt;code&gt;rm -rf&lt;/code&gt; anything)&lt;/li&gt;
&lt;li&gt;Resource creation that might cost more than you expected&lt;/li&gt;
&lt;li&gt;Security group or IAM changes that could open holes&lt;/li&gt;
&lt;li&gt;Anything touching production data&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The AI doesn't understand the blast radius of infrastructure changes the way you do. It will happily generate a script that nukes your database if that's technically what you asked for.&lt;/p&gt;

&lt;p&gt;For bigger infrastructure stuff, Terraform is great specifically because it has built-in safety mechanisms. But even then—review the plan output before applying.&lt;/p&gt;




&lt;h2&gt;
  
  
  Always Review, Always Ask Why
&lt;/h2&gt;

&lt;p&gt;This is kind of the meta-lesson that wraps everything else together.&lt;/p&gt;

&lt;p&gt;AI coding assistants will give you code. Lots of it. Fast. The temptation is to just ship it and move on. Don't.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What reviewing actually means:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Actually read the code. Not skim—read. Does the logic make sense?&lt;/li&gt;
&lt;li&gt;Ask for reasoning. "Why did you use this approach?" is totally valid. If the AI can't explain it well, that's a red flag.&lt;/li&gt;
&lt;li&gt;Ask for documentation. Ask the AI to document how things work, or document design decisions etc. post development.&lt;/li&gt;
&lt;li&gt;Give feedback. "This is too complex" or "Can we simplify?" pushes it toward better solutions.&lt;/li&gt;
&lt;li&gt;Check the edges. AI is great at the happy path. It's often weak on error handling, edge cases, and security stuff.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Wrapping Up
&lt;/h2&gt;

&lt;p&gt;After doing a lot of AI-assisted development, my productivity has genuinely gone way up. But not because the AI replaced my thinking—because it amplified it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The pattern that works:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;You decide the approach.&lt;/strong&gt; AI implements it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;You validate the output.&lt;/strong&gt; AI iterates based on your feedback.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;You catch the context-specific stuff.&lt;/strong&gt; AI doesn't know your infrastructure, your security requirements, or your users.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;You stay curious.&lt;/strong&gt; Ask why. Push back. Give direction.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;We're the architects.&lt;/p&gt;

</description>
      <category>programming</category>
      <category>ai</category>
      <category>agents</category>
      <category>beginners</category>
    </item>
    <item>
      <title>A.I. — The Amplifier: From Software Developer to Software Creator 🚀</title>
      <dc:creator>Forrester Terry</dc:creator>
      <pubDate>Tue, 20 Jan 2026 16:00:00 +0000</pubDate>
      <link>https://dev.to/sweetpapa/ai-the-amplifier-from-software-developer-to-software-creator-2nb9</link>
      <guid>https://dev.to/sweetpapa/ai-the-amplifier-from-software-developer-to-software-creator-2nb9</guid>
      <description>&lt;p&gt;A.I. will make the bad "badder", the rich richer, the poor poorer, the hopeful more hopeful, the doubtful more doubtful. It's given people the ability to do more with less—and less with more. It is the double-edged sword that is both blessing and curse.&lt;/p&gt;

&lt;p&gt;The question isn't &lt;em&gt;whether&lt;/em&gt; A.I. will be good or bad for humanity. It'll be both. We know this.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The real question is:&lt;/strong&gt; How much of a force multiplier will it be on the things that matter most? And where will that take us?&lt;/p&gt;




&lt;h2&gt;
  
  
  What I'm Seeing Out There 📊
&lt;/h2&gt;

&lt;p&gt;Let me be honest about what's happening in our industry right now.&lt;/p&gt;

&lt;p&gt;Junior developer roles have collapsed. Entry-level tech postings fell &lt;a href="https://www.hiringlab.org/" rel="noopener noreferrer"&gt;60% between 2022-2024&lt;/a&gt;, and Big Tech hired only 7% new grads in 2024. At the same time, the barrier to entry for &lt;em&gt;creating&lt;/em&gt; has never been lower. &lt;a href="https://suno.com" rel="noopener noreferrer"&gt;Suno&lt;/a&gt; has 12+ million users making music. Over 15 billion AI images have been generated. GitHub Copilot users complete tasks &lt;a href="https://github.blog/news-insights/research/research-quantifying-github-copilots-impact-on-developer-productivity-and-happiness/" rel="noopener noreferrer"&gt;55% faster&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;A.I. makes mistakes AND solves age-old math problems. It takes jobs and creates some. It's used to &lt;a href="https://www.thelancet.com/journals/lanonc/article/PIIS1470-2045(23)00298-X/fulltext" rel="noopener noreferrer"&gt;improve breast cancer detection throughput by 44%&lt;/a&gt;, and it's used in warfare and surveillance.&lt;/p&gt;

&lt;p&gt;Among all this -- it is the end of software developers as we knew them—and the start of something new: &lt;strong&gt;The Software Creator.&lt;/strong&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  ❓ "Should I Still Learn Software Development?"
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Short answer: Yes.&lt;/strong&gt; These tools are not bulletproof. Not even close.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fq08bybekbx41bapnpk9d.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fq08bybekbx41bapnpk9d.png" alt=" " width="800" height="480"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  What I've Learned About A.I. Capabilities
&lt;/h3&gt;

&lt;p&gt;I think of A.I. agents like employees I'm onboarding. Right now, A.I. performs at junior-to-mid level for routine, well-defined tasks—but falls &lt;em&gt;well below&lt;/em&gt; junior on complex system changes and architectural decisions.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Task Type&lt;/th&gt;
&lt;th&gt;AI Performance&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Single functions (&lt;a href="https://github.com/openai/human-eval" rel="noopener noreferrer"&gt;HumanEval&lt;/a&gt;)&lt;/td&gt;
&lt;td&gt;90-96% ✅&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Standard GitHub issues&lt;/td&gt;
&lt;td&gt;70-76% 🟡&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Complex real-world problems&lt;/td&gt;
&lt;td&gt;17-23% ❌&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The breadth of knowledge is WIDE, but not DEEP. I learned this the hard way building an AI-powered chatbot for my team—the thing could answer simple questions beautifully, but the moment someone asked something that required understanding our specific infrastructure (or a tool call gave bad info), it would confidently hallucinate an answer that sounded perfect but was completely wrong.&lt;/p&gt;

&lt;p&gt;Additionally if you don't know how to ask, &lt;em&gt;"WHY are you doing it that way?"&lt;/em&gt; or better yet, &lt;em&gt;"WHOA, please don't do that, do this instead,"&lt;/em&gt; you'll get taken down a rabbit hole of confident failure.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Real Productivity Numbers (They're Messier Than You Think)
&lt;/h3&gt;

&lt;p&gt;You've probably heard "AI gets you 80% there." The data tells a more honest story.&lt;/p&gt;

&lt;p&gt;GitHub Copilot generates &lt;a href="https://github.blog/news-insights/research/survey-ai-wave-grows/" rel="noopener noreferrer"&gt;46% of code&lt;/a&gt; for active users, but the acceptance rate averages only &lt;strong&gt;30%&lt;/strong&gt;—meaning 70% of suggestions get rejected. &lt;a href="https://survey.stackoverflow.co/2025/" rel="noopener noreferrer"&gt;66% of developers&lt;/a&gt; say their top frustration is "AI solutions that are almost right, but not quite." And here's the kicker: a &lt;a href="https://metr.github.io/autonomy-evals-guide/elicitation-protocol/" rel="noopener noreferrer"&gt;METR randomized controlled trial&lt;/a&gt; found developers actually took &lt;strong&gt;19% longer&lt;/strong&gt; with AI—while &lt;em&gt;believing&lt;/em&gt; they were 20% faster. 🤯&lt;/p&gt;

&lt;p&gt;I've felt this myself. There's something intoxicating about watching code appear on your screen. You &lt;em&gt;feel&lt;/em&gt; productive. But then you spend an hour debugging something the AI introduced three suggestions ago, and you realize your "80% there" was actually "60% there with new bugs."&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Realistic ratio: 60/40 or 70/30.&lt;/strong&gt; That "last mile" is longer than it looks.&lt;/p&gt;




&lt;h2&gt;
  
  
  🛠️ What Should You Actually Learn?
&lt;/h2&gt;

&lt;p&gt;You don't need to know everything overnight. I didn't. I came into this field without a computer science degree and learned everything on the job over 11+ years. Buy tools for your garage as you need them—same principle here.&lt;/p&gt;

&lt;h3&gt;
  
  
  Start With the Foundations
&lt;/h3&gt;

&lt;p&gt;Learn the basics first: variables, functions, classes. These are universal to any modern language. Here's my unpopular opinion: build something simple &lt;em&gt;without&lt;/em&gt; A.I. first. That trial-and-error is what makes you stronger. It's what lets you recognize when the AI is leading you astray.&lt;/p&gt;

&lt;p&gt;And learn Git. Non-negotiable. This will be important for keeping your code and the A.I.'s code on track.&lt;/p&gt;

&lt;h3&gt;
  
  
  Then Build Your Stack
&lt;/h3&gt;

&lt;p&gt;Backend fundamentals matter—Firebase, Express/Node, Flask. Understand what an API &lt;em&gt;is&lt;/em&gt; and how to stand one up. If you're working with AI agents, TypeScript + Zod (or Pydantic for Python folks) become critical. Type definitions and data validation are how you keep AI-generated code from doing something unexpected at runtime.&lt;/p&gt;

&lt;p&gt;Pick up basic testing with Jest or pytest. Here's a common trick I practice: make the AI write tests, then make it run them. It's a forcing function for quality.&lt;/p&gt;

&lt;p&gt;Security basics should be non-negotiable too. Don't put secrets in frontend code (I've seen this more than I'd like to admit). Understand OAuth and auth flows. Use a secret manager.&lt;/p&gt;

&lt;h3&gt;
  
  
  Level Up When You're Ready
&lt;/h3&gt;

&lt;p&gt;Cross-platform frameworks like Electron, Capacitor, and Quasar open up new possibilities when you're ready for them. Docker is technically a "bonus" but honestly, just learn it. Your future self will thank you.&lt;/p&gt;




&lt;h2&gt;
  
  
  💼 "How Do I Get a Job?"
&lt;/h2&gt;

&lt;h3&gt;
  
  
  If You're Starting from Zero
&lt;/h3&gt;

&lt;p&gt;The barrier for entry is higher now. I won't sugarcoat that. But I've hired people, and I can tell you what actually moves the needle.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;First, build a real portfolio WITH A.I.&lt;/strong&gt; Release software on GitHub that's actually useful. Demonstrate you can go from idea to reality. But here's the crucial part: &lt;em&gt;understand it under the hood and be able to explain it.&lt;/em&gt; I've interviewed candidates who built impressive-looking projects but couldn't explain basic architectural decisions. That's a red flag.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Second, bring genuine enthusiasm.&lt;/strong&gt; I'll take someone who's green but humble and eager over someone excellent but difficult to work with every single time. Your soft skills matter more than ever in a world where AI can write code. The human stuff—collaboration, communication, judgment—that's your edge.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Third, develop AI skills beyond basic prompting.&lt;/strong&gt; Job postings for "prompt engineers" &lt;a href="https://www.hiringlab.org/" rel="noopener noreferrer"&gt;peaked in April 2023&lt;/a&gt; and have plateaued since. Basic prompting is table stakes now. What employers actually want is system design and architecture, MLOps and production deployment, LLM fine-tuning and RAG development, and critical evaluation of AI outputs.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fv3cjzwqmw7igmxvcv0lc.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fv3cjzwqmw7igmxvcv0lc.jpeg" alt=" " width="800" height="436"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Jobs mentioning AI skills pay a &lt;a href="https://www.cnbc.com/2024/03/04/employees-with-ai-skills-can-expect-a-25-percent-salary-premium.html" rel="noopener noreferrer"&gt;28% premium (~$18K/year)&lt;/a&gt;, rising to 43% for multiple AI skills.&lt;/p&gt;

&lt;h3&gt;
  
  
  If You're Mid-Level or Beyond
&lt;/h3&gt;

&lt;p&gt;&lt;del&gt;Move into management because those jobs are safer. Right???&lt;/del&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Nah.&lt;/strong&gt; The data actually shows middle managers comprised &lt;a href="https://www.revelio.com/" rel="noopener noreferrer"&gt;32% of 2023 layoffs&lt;/a&gt;, and companies like Microsoft, Amazon, and Meta are explicitly flattening org structures. "The Great Flattening" is real. I say this as someone in management—the title alone doesn't protect you.&lt;/p&gt;

&lt;p&gt;What actually works is becoming a force multiplier. Use A.I. to do an amazing job at what your employer cares about. I've built reports and automations that would have taken weeks and compressed them into days. That's the kind of thing that gets noticed.&lt;/p&gt;

&lt;p&gt;Learn the tools deeply. Explore, play around, but focus on what connects to your actual job. Build with A.I. agents—learn how to orchestrate them, multitask with them, and free up your time for the work that actually requires human judgment.&lt;/p&gt;

&lt;p&gt;Lead without the title. Technical design, mentorship, and judgment are human superpowers. No AI is going to sit down with a frustrated junior dev and help them work through impostor syndrome.&lt;/p&gt;

&lt;p&gt;This is what transforms you from Software Developer → &lt;strong&gt;Software Creator&lt;/strong&gt; → &lt;strong&gt;A.I. Orchestrator&lt;/strong&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  🎮 How I Got Started with A.I.
&lt;/h2&gt;

&lt;p&gt;Here's roughly how my journey went:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Phase&lt;/th&gt;
&lt;th&gt;What I Learned&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;🎨 &lt;strong&gt;Image Gen&lt;/strong&gt;
&lt;/td&gt;
&lt;td&gt;Started with Stable Diffusion. Check out &lt;a href="https://flux-ai.io/" rel="noopener noreferrer"&gt;Flux&lt;/a&gt;, &lt;a href="https://deepmind.google/technologies/imagen-3/" rel="noopener noreferrer"&gt;Imagen&lt;/a&gt;, Midjourney&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;💬 &lt;strong&gt;Chatbots&lt;/strong&gt;
&lt;/td&gt;
&lt;td&gt;ChatGPT, Claude, Gemini. Learned context windows, tokens, prompting&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;🤖 &lt;strong&gt;Coding Agents&lt;/strong&gt;
&lt;/td&gt;
&lt;td&gt;
&lt;a href="https://cursor.sh/" rel="noopener noreferrer"&gt;Cursor&lt;/a&gt;, &lt;a href="https://codeium.com/windsurf" rel="noopener noreferrer"&gt;Windsurf&lt;/a&gt;, Claude Code—AI edits code locally&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;🔧 &lt;strong&gt;Building Agents&lt;/strong&gt;
&lt;/td&gt;
&lt;td&gt;
&lt;a href="https://www.crewai.com/" rel="noopener noreferrer"&gt;CrewAI&lt;/a&gt;, &lt;a href="https://www.langchain.com/" rel="noopener noreferrer"&gt;LangChain&lt;/a&gt;, MCP servers&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;🔬 &lt;strong&gt;Deep Research&lt;/strong&gt;
&lt;/td&gt;
&lt;td&gt;
&lt;a href="https://deepmind.google/technologies/gemini/" rel="noopener noreferrer"&gt;Gemini Deep Research&lt;/a&gt;, NotebookLM for studying&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;🏠 &lt;strong&gt;Running Local&lt;/strong&gt;
&lt;/td&gt;
&lt;td&gt;
&lt;a href="https://ollama.ai/" rel="noopener noreferrer"&gt;Ollama&lt;/a&gt;, vLLM, fine-tuning your own models, RAG&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Take it one step at a time. I spent months in each phase before moving to the next. You don't need all of this at once.&lt;/p&gt;




&lt;h2&gt;
  
  
  ⚠️ Real Talk: What's Coming
&lt;/h2&gt;

&lt;p&gt;I'd be crazy to tell you not to be concerned. A lot is changing. But here's how I think about it:&lt;/p&gt;

&lt;p&gt;A.I. amplifies what people already do—good and bad. People generally want everyone to be well off (so they can be well off too). And people don't like being squashed or oppressed.&lt;/p&gt;

&lt;p&gt;We're going to figure things out, as we have before. But it'll take work.&lt;/p&gt;

&lt;h3&gt;
  
  
  What About "The Next Big Thing"?
&lt;/h3&gt;

&lt;p&gt;You might hear about transformer alternatives, neurosymbolic AI, quantum computing integration. Here's my honest read on these:&lt;/p&gt;

&lt;p&gt;Transformer alternatives like hybrid models exist (Jamba, Granite 4.0), but transformers remain central. We're seeing augmentation, not replacement. Neurosymbolic AI produced impressive results with &lt;a href="https://deepmind.google/discover/blog/alphageometry-an-olympiad-level-ai-system-for-geometry/" rel="noopener noreferrer"&gt;AlphaGeometry&lt;/a&gt;, but no major LLM has shipped a general product yet. And quantum + AI? Jensen Huang estimates &lt;a href="https://www.nvidia.com/en-us/" rel="noopener noreferrer"&gt;15-30 years&lt;/a&gt; for "very useful" applications.&lt;/p&gt;

&lt;p&gt;These are &lt;strong&gt;research directions to watch&lt;/strong&gt;, not imminent paradigm shifts. Focus on what works today.&lt;/p&gt;




&lt;h2&gt;
  
  
  🎯 The Bottom Line
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Yes, still learn software development.&lt;/strong&gt; It's still worthwhile.&lt;/p&gt;

&lt;p&gt;But understand this: the role is transforming. The developers who thrive will be the ones who become &lt;strong&gt;creators&lt;/strong&gt;—people who can direct A.I. tools with expertise, know when to trust output and when to override, build entire systems (not just write code), and amplify their output through orchestration.&lt;/p&gt;

&lt;p&gt;Be kind to each other, and be kind to yourself. Be curious.&lt;/p&gt;

&lt;p&gt;The future will be great and problematic. You need to know how to spot deepfakes, understand security risks, and leverage the tools—otherwise you'll be pushed out.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;But you've got this.&lt;/strong&gt; 🤝&lt;/p&gt;




&lt;p&gt;&lt;em&gt;What's your experience with A.I. in your development workflow? Are you a skeptic, an enthusiast, or somewhere in between? Drop a comment below!&lt;/em&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>webdev</category>
      <category>career</category>
      <category>beginners</category>
    </item>
    <item>
      <title>I Have Bipolar II and I'm a Software Engineering Manager. Here's What Actually Works.</title>
      <dc:creator>Forrester Terry</dc:creator>
      <pubDate>Sun, 18 Jan 2026 17:00:00 +0000</pubDate>
      <link>https://dev.to/sweetpapa/i-have-bipolar-ii-and-im-a-software-engineering-manager-heres-what-actually-works-c14</link>
      <guid>https://dev.to/sweetpapa/i-have-bipolar-ii-and-im-a-software-engineering-manager-heres-what-actually-works-c14</guid>
      <description>&lt;p&gt;I've been in higher education IT for over 11 years. I've gotten "Exceptional Year" ratings. I manage a team of four devs and a portfolio of 20+ apps.&lt;/p&gt;

&lt;p&gt;I also have Bipolar II, diabetes, and I'm a recovering alcoholic — sober since 2020.&lt;/p&gt;

&lt;p&gt;If you're a dev managing your own stuff, this is for you. Not quite the “inspirational” version, but real nonetheless.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Real Version
&lt;/h2&gt;

&lt;p&gt;The performance reviews say things like "force multiplier" and "technical backbone." What they don't capture: the hypomanic phases where I'd fire off more ideas than anyone could implement, followed by crashes where getting out of bed felt impossible. The time I sent an apology email to my entire IT org while manic, outing myself as bipolar to hundreds of people. The years I used alcohol to manage what my brain wouldn't.&lt;/p&gt;

&lt;p&gt;When I got sober, I replaced drinking with work. Classic move, right? The dopamine hit of shipping code. The validation of being the guy who solves the "impossible" problems.&lt;/p&gt;

&lt;p&gt;Then I lost my brother. And somewhere in the grief, I realized I was going to burn out completely if I didn't change how I thought about all of this.&lt;/p&gt;




&lt;h2&gt;
  
  
  Your Health Isn't a Side Quest
&lt;/h2&gt;

&lt;p&gt;Here's what took me way too long to accept: managing my health isn't something I do &lt;em&gt;around&lt;/em&gt; my job. It IS the job. Everything else comes after. Especially more so as I stepped into leadership and became responsible for others.&lt;/p&gt;

&lt;p&gt;Bipolar and diabetes create this feedback loop — mood affects blood sugar, blood sugar wrecks mood, stress spikes everything. It's not a metaphor. It's just how the body works.&lt;/p&gt;

&lt;p&gt;I tried to brute-force through it for years. Push harder, sleep less, prove I could keep up. You know where that leads.&lt;/p&gt;




&lt;h2&gt;
  
  
  Spoon Theory, Basically
&lt;/h2&gt;

&lt;p&gt;If you don't know Spoon Theory: you start each day with limited "spoons" (energy units). Every task costs spoons. When they're gone, they're gone. Borrow from tomorrow and you pay interest in a crashed mood or spiked glucose.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F295376erygh9zabh4y9i.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F295376erygh9zabh4y9i.jpeg" alt=" " width="800" height="436"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So I stopped organizing work by priority and started organizing by energy cost:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;High-energy stuff&lt;/strong&gt; (architecture, hard conversations) → morning when I'm sharp
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Medium stuff&lt;/strong&gt; (code reviews, meetings) → afternoon
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Low-energy stuff&lt;/strong&gt; (email, docs) → the valleys&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffpamr2f7b25tmalixowh.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffpamr2f7b25tmalixowh.jpeg" alt=" " width="800" height="436"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I built a hybrid system by literally just talking through my constraints with AI over a bunch of sessions. GTD for capturing everything, time blocking for structure, Pomodoro for pushing through fog. Nothing fancy. Just honest about what I'm actually working with.&lt;/p&gt;

&lt;p&gt;The key insight: &lt;strong&gt;rest isn't the opposite of work. It's what makes work possible.&lt;/strong&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Making Myself Less Necessary
&lt;/h2&gt;

&lt;p&gt;Here's the weird part: my limitations made me a better manager.&lt;/p&gt;

&lt;p&gt;When you can't be the hero pulling all-nighters, you build systems that don't need heroes. When you know a depressive episode could knock you out for days, you write documentation and processes that let your team function without you.&lt;/p&gt;

&lt;p&gt;Practically:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Reusable code libraries so we're not reinventing stuff
&lt;/li&gt;
&lt;li&gt;Documentation that's actually useful (AI memory, not bureaucracy)
&lt;/li&gt;
&lt;li&gt;Mentoring junior devs into mentors themselves
&lt;/li&gt;
&lt;li&gt;Automating the tedious stuff — CI/CD, release notes, deployments&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The goal is to make myself progressively less necessary. Sounds bad for career advancement, but actually? The good orgs reward people who elevate everyone around them, not people who hoard knowledge.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Humbling Part
&lt;/h2&gt;

&lt;p&gt;I gotta be honest: I've watched people who output less than me get more recognition. And a lot of the time, they deserved it.&lt;/p&gt;

&lt;p&gt;Because they were &lt;strong&gt;consistent&lt;/strong&gt;. &lt;strong&gt;Reliable&lt;/strong&gt;. They showed up steady every day.&lt;/p&gt;

&lt;p&gt;When you're managing Bipolar, consistency is hard. Hypomania feels productive but creates chaos. Depression tanks your reliability. Boom-and-bust might average to high output, but it's not the same as being someone people can count on.&lt;/p&gt;

&lt;p&gt;My work feedback survey shows I rate myself way harsher than my team does — like 2 out of 5 on stuff they score me 4.6. That gap is years of feeling like I had to compensate for my brain by being visibly exceptional.&lt;/p&gt;

&lt;p&gt;The truth: &lt;strong&gt;sustainable and reliable beats exceptional and erratic.&lt;/strong&gt; Every time.&lt;/p&gt;




&lt;h2&gt;
  
  
  Environment Matters More Than Salary
&lt;/h2&gt;

&lt;p&gt;I work in higher ed, not FAANG. Not where the big money is. This is intentional.&lt;/p&gt;

&lt;p&gt;I've had the same leadership for 11+ years and enjoy working with my directorl. When I've struggled — visibly — I wasn't managed out. I was supported. That kind of psychological safety is worth more than any salary bump I'd get jumping to a high-pressure gig.&lt;/p&gt;

&lt;p&gt;If you're managing chronic stuff, environment isn't a perk. It's infrastructure. The right manager, the right culture, the right flexibility — that's what makes everything else possible.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Short Version
&lt;/h2&gt;

&lt;p&gt;If you're a dev fighting similar battles:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Don’t pretend that you have the same resources as everyone else.&lt;/strong&gt; You don't. Build systems for your actual constraints.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Energy management &amp;gt; time management.&lt;/strong&gt; Know your peaks and valleys.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Rest is productive.&lt;/strong&gt; For real.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Make yourself less necessary.&lt;/strong&gt; Document, automate, mentor.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Consistency beats intensity.&lt;/strong&gt; 70% every day beats 150% half the time.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Environment is infrastructure.&lt;/strong&gt; A good manager isn't a luxury.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Your inner critic lies.&lt;/strong&gt; Get external feedback. Trust it more than the voice saying you're not enough.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Work can be an addiction too.&lt;/strong&gt; Ask me how I know.&lt;/li&gt;
&lt;/ol&gt;




&lt;p&gt;Work-life balance isn't a myth. For some of us, it's a survival strategy.&lt;/p&gt;

&lt;p&gt;I'm not writing this from the other side, all figured out. I'm in the middle, still managing the loops, still learning what sustainable looks like.&lt;/p&gt;

&lt;p&gt;But I'm still here doing my thing. Still shipping code. Still leading a team.&lt;/p&gt;

&lt;p&gt;If you're fighting similar stuff — you can do this.&lt;/p&gt;

&lt;p&gt;Not by pretending you don't have limits, but by building systems that work with them.&lt;/p&gt;

&lt;p&gt;That's not settling. That's engineering.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;If this resonates at all or made you think about something else, I'd love to hear from others.&lt;/em&gt;  &lt;/p&gt;

</description>
      <category>mentalhealth</category>
      <category>career</category>
      <category>careerdevelopment</category>
    </item>
    <item>
      <title>Part 1 : Building a Game in 30 Hours Using AI — Here's the Actual Timeline</title>
      <dc:creator>Forrester Terry</dc:creator>
      <pubDate>Fri, 16 Jan 2026 00:22:34 +0000</pubDate>
      <link>https://dev.to/sweetpapa/part-1-building-a-game-in-30-hours-using-ai-heres-the-actual-timeline-1dj5</link>
      <guid>https://dev.to/sweetpapa/part-1-building-a-game-in-30-hours-using-ai-heres-the-actual-timeline-1dj5</guid>
      <description>&lt;p&gt;What happens when you treat AI as a development partner instead of an autocomplete tool?&lt;/p&gt;

&lt;p&gt;I wanted to find out, so I ran an experiment: build a game as fast as possible, prioritizing speed and iteration over polish. No extensive planning phase. No detailed specs. Just prototyping at velocity to see what's actually possible.&lt;/p&gt;

&lt;p&gt;The result is &lt;a href="https://maglava.io" rel="noopener noreferrer"&gt;MagLava&lt;/a&gt;—a magnetic platformer where you swing between nodes to escape rising lava. Six development sessions. Roughly 30 hours of work. A published game with 25 levels, 7 language translations, and a desktop app.&lt;/p&gt;

&lt;p&gt;To be clear: this approach was the point of the experiment. For production software or anything beyond rapid prototyping, proper planning and testing remain essential (I plan to make a post around that later).&lt;/p&gt;

&lt;p&gt;But I wanted to stress-test the other extreme.&lt;/p&gt;

&lt;p&gt;Here's exactly how that broke down.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Commit Log
&lt;/h2&gt;

&lt;p&gt;I commit frequently using an AI tool that generates summaries after each task, so commit clusters map well to actual work sessions. I went through my git history and reconstructed the timeline:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Date&lt;/th&gt;
&lt;th&gt;Commits&lt;/th&gt;
&lt;th&gt;Estimated Time&lt;/th&gt;
&lt;th&gt;What Happened&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Dec 18&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;~1.5 hours&lt;/td&gt;
&lt;td&gt;Project scaffold, Vue + Phaser setup&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Dec 19&lt;/td&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;td&gt;~2-3 hours&lt;/td&gt;
&lt;td&gt;Core magnetic polarity system&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Dec 20&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;27&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;~8-12 hours&lt;/td&gt;
&lt;td&gt;Complete movement redesign + 15 levels&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Dec 21&lt;/td&gt;
&lt;td&gt;9&lt;/td&gt;
&lt;td&gt;~4-6 hours&lt;/td&gt;
&lt;td&gt;Mobile controls, tutorials, PWA&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Dec 30&lt;/td&gt;
&lt;td&gt;13&lt;/td&gt;
&lt;td&gt;~5-7 hours&lt;/td&gt;
&lt;td&gt;Desktop app, music, polish&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Jan 15&lt;/td&gt;
&lt;td&gt;8&lt;/td&gt;
&lt;td&gt;~3-5 hours&lt;/td&gt;
&lt;td&gt;i18n (7 languages), expand to 25 levels&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Total: ~25-35 hours across 6 sessions.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Notice the gaps. Nine days between Dec 21 and Dec 30. Sixteen days before the final session. The calendar says "one month of development." The reality is about a week of actual work, scattered across that month.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fx2x40w5j1y4lod3ap2ky.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fx2x40w5j1y4lod3ap2ky.png" alt="Gameplay" width="438" height="896"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What "AI-Assisted" Actually Meant
&lt;/h2&gt;

&lt;p&gt;The first day alone produced 6,555 lines of code—project structure, game config, menu systems, routing, storage services, the event bridge between Vue and Phaser. That's scaffolding I would have spent days on manually.&lt;/p&gt;

&lt;p&gt;But the surprising part wasn't the code generation. It was what else came out of the process.&lt;/p&gt;

&lt;p&gt;The promotional website with SEO, sitemaps, and structured data? AI-built. The full Electron desktop app with the level editor? Same story. The internationalization system supporting 7 languages? Implemented in a single session.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fu74nz9unkecnwpa9bta0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fu74nz9unkecnwpa9bta0.png" alt="I was able to build a cross platform level editor in less than a day" width="800" height="411"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I didn't set out to have AI handle all of these. They emerged because once you're in a flow state with an AI partner, the friction for "one more feature" drops dramatically. Adding a desktop build went from "future roadmap item" to "let's just do it this session."&lt;/p&gt;

&lt;h2&gt;
  
  
  The Method Behind the Numbers
&lt;/h2&gt;

&lt;p&gt;You might have heard the term "vibe coding"— in this case, staying in player mode and describing problems experientially rather than technically. That's what this looked like in practice. Here's an actual prompt from one of my sessions:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"game just freezes! I can't actually SEE the LAVA LINE!!! I WANA SEE THE LAVA line. And finally, we start way too close to the lava."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Typos, caps lock, frustration—all of it. I didn't calculate a pixel buffer. I expressed a feeling of unfairness. The AI translated "way too close" into a concrete fix: increasing the spawn buffer from 150 to 500 pixels above the lava line.&lt;/p&gt;

&lt;p&gt;This only works because emotion &lt;em&gt;is&lt;/em&gt; a valid technical spec when your goal is player experience. "This feels unfair" contains more design information than "adjust the Y-offset parameter."&lt;/p&gt;

&lt;h2&gt;
  
  
  Why the Timeline Matters
&lt;/h2&gt;

&lt;p&gt;I'm not claiming 30 hours is fast or slow. Game complexity varies wildly. What I am claiming is that this timeline was &lt;em&gt;possible&lt;/em&gt; because of how I worked, not just the tools I used.&lt;/p&gt;

&lt;p&gt;The traditional solo dev pipeline looks like this: plan extensively, build the architecture, implement features, then test. You front-load decisions before you have information.&lt;/p&gt;

&lt;p&gt;My pipeline inverted that. Build something immediately. Play it. Describe what feels wrong. Iterate. The AI handled the translation from "this sucks" to "here's the code change."&lt;/p&gt;

&lt;p&gt;Every system stayed disposable. Every change stayed focused and modular. When something wasn't working, I didn't defend it—I described a different vision and let it get rebuilt. That's hard to do when you've personally written every line. It's easy when you're directing rather than typing.&lt;/p&gt;

&lt;h2&gt;
  
  
  What the Numbers Don't Show
&lt;/h2&gt;

&lt;p&gt;The timeline looks clean in retrospect. It wasn't.&lt;/p&gt;

&lt;p&gt;Day 3—that massive 27-commit session—included throwing away the entire movement system I'd built on Day 2. The original concept was polarity-based climbing: red platforms attract, blue platforms repel. I built the whole thing. Then I played it and it felt indirect, frustrating, disconnected from what I actually wanted.&lt;/p&gt;

&lt;p&gt;So I described something different: "I want swinging. Like Spider-Man but with magnets."&lt;/p&gt;

&lt;p&gt;Within hours, the game had a completely new identity.&lt;/p&gt;

&lt;p&gt;That pivot—and one other major pivot that came later—are probably the reason MagLava works at all. But that's a longer story.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Next in this series:&lt;/strong&gt; The two pivots that almost killed the project, and why emotional prompts caught problems that specs would have missed.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;a href="https://maglava.io" rel="noopener noreferrer"&gt;Play MagLava&lt;/a&gt; | &lt;a href="https://sweetpapatech.itch.io/maglava" rel="noopener noreferrer"&gt;itch.io page&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;




&lt;p&gt;&lt;small&gt;&lt;strong&gt;Tech stack for the curious:&lt;/strong&gt; Vue 3 + Vite, Phaser 3, TypeScript, Electron for desktop, Firebase + itch.io for hosting, Claude (Opus via Claude Code CLI) for AI assistance.&lt;/small&gt;&lt;/p&gt;

</description>
      <category>gamedev</category>
      <category>ai</category>
      <category>webdev</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Supercharging Your AI Agents with Pydantic: A Developer's Guide 🚀</title>
      <dc:creator>Forrester Terry</dc:creator>
      <pubDate>Fri, 28 Feb 2025 04:33:15 +0000</pubDate>
      <link>https://dev.to/sweetpapa/supercharging-your-ai-agents-with-pydantic-a-developers-guide-3hmk</link>
      <guid>https://dev.to/sweetpapa/supercharging-your-ai-agents-with-pydantic-a-developers-guide-3hmk</guid>
      <description>&lt;h2&gt;
  
  
  Table of Contents
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Introduction 👋&lt;/li&gt;
&lt;li&gt;
What is Pydantic and Why Should AI Developers Care? 🤔

&lt;ul&gt;
&lt;li&gt;The AI Agent's Output Problem 🤖💬&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

How Pydantic Makes AI Agents More Reliable 🛡️

&lt;ul&gt;
&lt;li&gt;1. Automatic Type Conversion&lt;/li&gt;
&lt;li&gt;2. Clear Error Messages&lt;/li&gt;
&lt;li&gt;3. Schema Generation for Guiding AI Outputs&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

Real-World Use Cases 🌍

&lt;ul&gt;
&lt;li&gt;OpenAI Function Calling + Pydantic&lt;/li&gt;
&lt;li&gt;Multi-Agent Systems (CrewAI)&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

Best Practices for Using Pydantic with AI Agents ✅

&lt;ul&gt;
&lt;li&gt;1. Start with a Clear Data Model&lt;/li&gt;
&lt;li&gt;2. Handle Validation Errors Gracefully&lt;/li&gt;
&lt;li&gt;3. Consider Re-Prompting When Validation Fails&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

A Simple Tutorial: Getting Started with Pydantic and AI 🏗️

&lt;ul&gt;
&lt;li&gt;Step 1: Define Your Pydantic Model&lt;/li&gt;
&lt;li&gt;Step 2: Create a Function to Get Recommendations from an AI&lt;/li&gt;
&lt;li&gt;Step 3: Use the Recommendation in Your Application&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

Advanced Tips and Tricks 🧠

&lt;ul&gt;
&lt;li&gt;Custom Validators for Domain-Specific Rules&lt;/li&gt;
&lt;li&gt;Nested Models for Complex Data&lt;/li&gt;
&lt;li&gt;Working with LangChain's Pydantic Output Parser&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;Conclusion 🎯&lt;/li&gt;

&lt;/ul&gt;

&lt;h2&gt;
  
  
  Introduction 👋
&lt;/h2&gt;

&lt;p&gt;Have you ever built an AI agent that sometimes returns unpredictable data structures? Or perhaps you've dealt with the frustration of parsing JSON from a language model only to have your application crash because a field was missing or had the wrong type?&lt;/p&gt;

&lt;p&gt;I've been there too! That's why today I want to talk about one of my favorite tools for taming the wild outputs of AI agents: &lt;strong&gt;Pydantic&lt;/strong&gt;!&lt;/p&gt;

&lt;p&gt;In this guide, I'll show you how Pydantic can transform your AI agent development from a game of chance into a reliable, robust process. Let's dive in! 🏊‍♂️&lt;/p&gt;

&lt;h2&gt;
  
  
  What is Pydantic and Why Should AI Developers Care? 🤔
&lt;/h2&gt;

&lt;p&gt;Pydantic is a Python library for data validation that uses type annotations. Think of it as a bouncer for your data - it checks IDs (types) at the door and makes sure only the right data gets into your application.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;pydantic&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;BaseModel&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;User&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;BaseModel&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;
    &lt;span class="n"&gt;age&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;int&lt;/span&gt;
    &lt;span class="n"&gt;is_active&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;bool&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But why is this particularly useful for AI agents? Here's the thing:&lt;/p&gt;

&lt;p&gt;AI models (especially LLMs) are amazing at generating content, but they're not always precise about formatting. They might return JSON where a number is accidentally a string (&lt;code&gt;"42"&lt;/code&gt; instead of &lt;code&gt;42&lt;/code&gt;), or they might forget a field entirely. Without validation, these small inconsistencies can cause big problems downstream in your application.&lt;/p&gt;

&lt;h3&gt;
  
  
  The AI Agent's Output Problem 🤖💬
&lt;/h3&gt;

&lt;p&gt;Imagine asking an AI agent to return information about a product:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Super Widget"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"price"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"29.99"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"in_stock"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"true"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"features"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"durable"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"lightweight"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Notice the issues? &lt;code&gt;price&lt;/code&gt; is a string instead of a float, and &lt;code&gt;in_stock&lt;/code&gt; is a string instead of a boolean. Your application might crash when it tries to do math with that price or make a decision based on the stock status.&lt;/p&gt;

&lt;p&gt;Pydantic to the rescue! It can automatically convert these types for you, so &lt;code&gt;"29.99"&lt;/code&gt; becomes &lt;code&gt;29.99&lt;/code&gt; (float) and &lt;code&gt;"true"&lt;/code&gt; becomes &lt;code&gt;True&lt;/code&gt; (boolean).&lt;/p&gt;

&lt;h2&gt;
  
  
  How Pydantic Makes AI Agents More Reliable 🛡️
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Automatic Type Conversion
&lt;/h3&gt;

&lt;p&gt;Pydantic doesn't just validate - it tries to convert data to the right type when possible. This is perfect for AI outputs that are &lt;em&gt;almost&lt;/em&gt; correct.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;pydantic&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;BaseModel&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Product&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;BaseModel&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;
    &lt;span class="n"&gt;price&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;float&lt;/span&gt;
    &lt;span class="n"&gt;in_stock&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;bool&lt;/span&gt;
    &lt;span class="n"&gt;features&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;list&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

&lt;span class="c1"&gt;# Even though price and in_stock are strings, Pydantic will convert them
&lt;/span&gt;&lt;span class="n"&gt;product&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Product&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Super Widget&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
    &lt;span class="n"&gt;price&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;29.99&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
    &lt;span class="n"&gt;in_stock&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;true&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;features&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;durable&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;lightweight&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;product&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="c1"&gt;# Product(name='Super Widget', price=29.99, in_stock=True, features=['durable', 'lightweight'])
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2. Clear Error Messages
&lt;/h3&gt;

&lt;p&gt;When validation fails, Pydantic tells you exactly what went wrong:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;try&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nc"&gt;Product&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Broken Widget&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;price&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;expensive&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;in_stock&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;features&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;strong&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;except&lt;/span&gt; &lt;span class="nb"&gt;Exception&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Error: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Error: 2 validation errors for Product
# price
#   Input should be a valid number, unable to parse string as a number [type=float_parsing, input_value='expensive', input_type=str]
# features
#   Input should be a valid list [type=list_type, input_value='strong', input_type=str]
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These detailed errors make debugging so much easier when your AI agent returns unexpected data.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Schema Generation for Guiding AI Outputs
&lt;/h3&gt;

&lt;p&gt;One of my favorite Pydantic features for AI development is its ability to generate JSON schemas:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Product&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;model_json_schema&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
&lt;span class="c1"&gt;# {
#   "title": "Product",
#   "type": "object",
#   "properties": {
#     "name": {"title": "Name", "type": "string"},
#     "price": {"title": "Price", "type": "number"},
#     "in_stock": {"title": "In Stock", "type": "boolean"},
#     "features": {
#       "title": "Features",
#       "type": "array",
#       "items": {"type": "string"}
#     }
#   },
#   "required": ["name", "price", "in_stock", "features"]
# }
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can use this schema to guide your AI model, especially if you're using function calling with OpenAI or similar features with other providers. This dramatically improves the chances of getting correctly formatted responses!&lt;/p&gt;

&lt;h2&gt;
  
  
  Real-World Use Cases 🌍
&lt;/h2&gt;

&lt;p&gt;Let's look at how developers are using Pydantic with AI agents in the wild:&lt;/p&gt;

&lt;h3&gt;
  
  
  OpenAI Function Calling + Pydantic
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;openai&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;OpenAI&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;pydantic&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;BaseModel&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Field&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;WeatherInfo&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;BaseModel&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;location&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Field&lt;/span&gt;&lt;span class="p"&gt;(...,&lt;/span&gt; &lt;span class="n"&gt;description&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;The city and state&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;temperature&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;float&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Field&lt;/span&gt;&lt;span class="p"&gt;(...,&lt;/span&gt; &lt;span class="n"&gt;description&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Current temperature in Celsius&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;condition&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Field&lt;/span&gt;&lt;span class="p"&gt;(...,&lt;/span&gt; &lt;span class="n"&gt;description&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Weather condition (sunny, cloudy, etc.)&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Get the JSON schema for OpenAI
&lt;/span&gt;&lt;span class="n"&gt;function_def&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;name&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;get_weather&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;description&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Get the current weather in a location&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;parameters&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;WeatherInfo&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;model_json_schema&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="n"&gt;client&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;OpenAI&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="n"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;chat&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;completions&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;create&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;gpt-4-turbo&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;messages&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;role&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;user&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;content&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;What&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;s the weather like in Boston?&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;],&lt;/span&gt;
    &lt;span class="n"&gt;functions&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;function_def&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
    &lt;span class="n"&gt;function_call&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;name&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;get_weather&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Extract and validate the response
&lt;/span&gt;&lt;span class="n"&gt;function_response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;choices&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="n"&gt;message&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;function_call&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;arguments&lt;/span&gt;
&lt;span class="n"&gt;weather&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;WeatherInfo&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;model_validate_json&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;function_response&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;It&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;s &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;weather&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;temperature&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;°C and &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;weather&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;condition&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt; in &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;weather&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;location&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This approach has two benefits:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The schema guides the AI to produce properly structured output&lt;/li&gt;
&lt;li&gt;Pydantic validates that output as an extra safety measure&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Multi-Agent Systems (CrewAI)
&lt;/h3&gt;

&lt;p&gt;In systems where multiple AI agents collaborate, consistent data structures are critical. Frameworks like CrewAI use Pydantic to ensure agents communicate properly:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;pydantic&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;BaseModel&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;crewai&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Agent&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Task&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Crew&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;ResearchReport&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;BaseModel&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;topic&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;
    &lt;span class="n"&gt;key_findings&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;list&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="n"&gt;sources&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;list&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

&lt;span class="c1"&gt;# Define a task with a Pydantic output schema
&lt;/span&gt;&lt;span class="n"&gt;research_task&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Task&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;description&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Research the latest advancements in quantum computing&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;expected_output&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;A structured research report with key findings and sources&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;output_pydantic&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;ResearchReport&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# When the agent completes the task, CrewAI validates the output against the model
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Best Practices for Using Pydantic with AI Agents ✅
&lt;/h2&gt;

&lt;p&gt;After working with numerous AI projects, here are my top recommendations:&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Start with a Clear Data Model
&lt;/h3&gt;

&lt;p&gt;Define Pydantic models that capture exactly what you need from your AI agent. Be specific about types and constraints:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;typing&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Optional&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Literal&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;pydantic&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;BaseModel&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Field&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;conint&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;ProductRecommendation&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;BaseModel&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;product_name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;
    &lt;span class="n"&gt;price_range&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Field&lt;/span&gt;&lt;span class="p"&gt;(...,&lt;/span&gt; &lt;span class="n"&gt;pattern&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sa"&gt;r&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;^\$\d+-\$\d+$&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="c1"&gt;# Ensure format like "$10-$20"
&lt;/span&gt;    &lt;span class="n"&gt;rating&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;conint&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ge&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;le&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="c1"&gt;# Integer between 1-5
&lt;/span&gt;    &lt;span class="n"&gt;category&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;Literal&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;electronics&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;clothing&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;home&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;books&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;other&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="n"&gt;features&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;list&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Field&lt;/span&gt;&lt;span class="p"&gt;(...,&lt;/span&gt; &lt;span class="n"&gt;min_items&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;max_items&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;in_stock&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;bool&lt;/span&gt;
    &lt;span class="n"&gt;shipping_days&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;Optional&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nb"&gt;int&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;None&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This detailed model serves as documentation and validation in one package.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Handle Validation Errors Gracefully
&lt;/h3&gt;

&lt;p&gt;Always wrap your Pydantic validation in try/except blocks:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;try&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;recommendation&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;ProductRecommendation&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;model_validate_json&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ai_response&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="c1"&gt;# Use the structured data
&lt;/span&gt;&lt;span class="k"&gt;except&lt;/span&gt; &lt;span class="nb"&gt;Exception&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="c1"&gt;# Log the error
&lt;/span&gt;    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;AI output validation failed: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="c1"&gt;# Possible strategies:
&lt;/span&gt;    &lt;span class="c1"&gt;# 1. Use a fallback approach
&lt;/span&gt;    &lt;span class="c1"&gt;# 2. Re-prompt the AI with the error details
&lt;/span&gt;    &lt;span class="c1"&gt;# 3. Apply some fixes and retry validation
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  3. Consider Re-Prompting When Validation Fails
&lt;/h3&gt;

&lt;p&gt;One powerful approach is to tell the AI exactly what went wrong and ask it to fix the response:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;get_validated_response&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;prompt&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;attempt&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nf"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;  &lt;span class="c1"&gt;# Try up to 3 times
&lt;/span&gt;        &lt;span class="n"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;ai_model&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;generate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;prompt&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

        &lt;span class="k"&gt;try&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;ProductRecommendation&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;model_validate_json&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;result&lt;/span&gt;
        &lt;span class="k"&gt;except&lt;/span&gt; &lt;span class="nb"&gt;Exception&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;attempt&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;  &lt;span class="c1"&gt;# Don't update prompt on the last attempt
&lt;/span&gt;                &lt;span class="n"&gt;prompt&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;Your previous response had validation errors: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;. Please fix them and try again.&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;

    &lt;span class="c1"&gt;# If we get here, all attempts failed
&lt;/span&gt;    &lt;span class="k"&gt;raise&lt;/span&gt; &lt;span class="nc"&gt;ValueError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Could not get valid response after multiple attempts&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This feedback loop helps the AI learn from its mistakes!&lt;/p&gt;

&lt;h2&gt;
  
  
  A Simple Tutorial: Getting Started with Pydantic and AI 🏗️
&lt;/h2&gt;

&lt;p&gt;Let's bring everything together with a simple tutorial. We'll create a movie recommendation agent that returns properly structured data:&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1: Define Your Pydantic Model
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;pydantic&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;BaseModel&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Field&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;typing&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;List&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Optional&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;MovieRecommendation&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;BaseModel&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;title&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;
    &lt;span class="n"&gt;year&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;int&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Field&lt;/span&gt;&lt;span class="p"&gt;(...,&lt;/span&gt; &lt;span class="n"&gt;ge&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;1900&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;le&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;2030&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;genres&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;List&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Field&lt;/span&gt;&lt;span class="p"&gt;(...,&lt;/span&gt; &lt;span class="n"&gt;min_items&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;rating&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;float&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Field&lt;/span&gt;&lt;span class="p"&gt;(...,&lt;/span&gt; &lt;span class="n"&gt;ge&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mf"&gt;0.0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;le&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mf"&gt;10.0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;director&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;
    &lt;span class="n"&gt;streaming_on&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;Optional&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;List&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;]]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;None&lt;/span&gt;
    &lt;span class="n"&gt;description&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Field&lt;/span&gt;&lt;span class="p"&gt;(...,&lt;/span&gt; &lt;span class="n"&gt;max_length&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;500&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 2: Create a Function to Get Recommendations from an AI
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;get_movie_recommendation&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;genre_preference&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;mood&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;decade_preference&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;None&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="c1"&gt;# Construct a prompt for the AI
&lt;/span&gt;    &lt;span class="n"&gt;prompt&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"""&lt;/span&gt;&lt;span class="s"&gt;
    Suggest a movie based on the following:
    Genre preference: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;genre_preference&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;
    Mood: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;mood&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;
    Decade preference: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;decade_preference&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;any&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;

    Return the recommendation as a JSON object with the following fields:
    - title: the movie title
    - year: the release year (1900-2030)
    - genres: list of genres
    - rating: rating out of 10
    - director: the director&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;s name
    - streaming_on: list of streaming platforms (if known) or null
    - description: brief description (max 500 chars)
    &lt;/span&gt;&lt;span class="sh"&gt;"""&lt;/span&gt;

    &lt;span class="c1"&gt;# In a real application, you'd call your AI model here
&lt;/span&gt;    &lt;span class="c1"&gt;# For demonstration, let's pretend we got this response:
&lt;/span&gt;    &lt;span class="n"&gt;ai_response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"""&lt;/span&gt;&lt;span class="s"&gt;
    {
      &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;title&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;: &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;The Grand Budapest Hotel&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;,
      &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;year&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;: 2014,
      &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;genres&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;: [&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Comedy&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;, &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Drama&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;, &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Adventure&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;],
      &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;rating&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;: 8.1,
      &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;director&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;: &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Wes Anderson&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;,
      &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;streaming_on&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;: [&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;HBO Max&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;, &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Disney+&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;],
      &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;description&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;: &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;A writer encounters the owner of an aging high-class hotel, who tells him of his early years serving as a lobby boy in the hotel&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;s glorious years under an exceptional concierge.&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;
    }
    &lt;/span&gt;&lt;span class="sh"&gt;"""&lt;/span&gt;

    &lt;span class="k"&gt;try&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="c1"&gt;# Parse and validate the AI response
&lt;/span&gt;        &lt;span class="n"&gt;recommendation&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;MovieRecommendation&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;model_validate_json&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ai_response&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;recommendation&lt;/span&gt;
    &lt;span class="k"&gt;except&lt;/span&gt; &lt;span class="nb"&gt;Exception&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Error validating AI response: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="c1"&gt;# In a real application, you might implement retry logic here
&lt;/span&gt;        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="bp"&gt;None&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 3: Use the Recommendation in Your Application
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;display_recommendation&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;recommendation&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;recommendation&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Sorry, couldn&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;t generate a valid recommendation.&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;

    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"""&lt;/span&gt;&lt;span class="s"&gt;
    🎬 &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;recommendation&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;title&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt; (&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;recommendation&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;year&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;) - &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;recommendation&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;rating&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;/10

    Directed by: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;recommendation&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;director&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;
    Genres: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;, &lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;recommendation&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;genres&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;

    &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;recommendation&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;description&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;

    &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Available on&lt;/span&gt;&lt;span class="si"&gt;:&lt;/span&gt; &lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;, &lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;recommendation&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;streaming_on&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt; if recommendation.streaming_on else &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="n"&gt;Streaming&lt;/span&gt; &lt;span class="n"&gt;info&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;available&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;
    &lt;/span&gt;&lt;span class="sh"&gt;"""&lt;/span&gt;

&lt;span class="c1"&gt;# Get and display a recommendation
&lt;/span&gt;&lt;span class="n"&gt;user_genre&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;sci-fi&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
&lt;span class="n"&gt;user_mood&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;thoughtful&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
&lt;span class="n"&gt;user_decade&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;2010s&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;

&lt;span class="n"&gt;movie&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;get_movie_recommendation&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;user_genre&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;user_mood&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;user_decade&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;display_recommendation&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;movie&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Advanced Tips and Tricks 🧠
&lt;/h2&gt;

&lt;p&gt;Want to take your Pydantic + AI game to the next level? Here are some advanced techniques:&lt;/p&gt;

&lt;h3&gt;
  
  
  Custom Validators for Domain-Specific Rules
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;pydantic&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;BaseModel&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Field&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;validator&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;TravelRecommendation&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;BaseModel&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;destination&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;
    &lt;span class="n"&gt;best_months&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;list&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="n"&gt;budget_usd&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;int&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Field&lt;/span&gt;&lt;span class="p"&gt;(...,&lt;/span&gt; &lt;span class="n"&gt;gt&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="nd"&gt;@validator&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;best_months&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;check_valid_months&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;cls&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;months&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;valid_months&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;January&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;February&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;March&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;April&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;May&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;June&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
                      &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;July&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;August&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;September&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;October&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;November&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;December&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;month&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;months&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;month&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;valid_months&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="k"&gt;raise&lt;/span&gt; &lt;span class="nc"&gt;ValueError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Invalid month: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;month&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;months&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Nested Models for Complex Data
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Address&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;BaseModel&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;street&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;
    &lt;span class="n"&gt;city&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;
    &lt;span class="n"&gt;state&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;
    &lt;span class="n"&gt;country&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;
    &lt;span class="n"&gt;postal_code&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Contact&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;BaseModel&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;
    &lt;span class="n"&gt;email&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;
    &lt;span class="n"&gt;phone&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;Optional&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;None&lt;/span&gt;
    &lt;span class="n"&gt;address&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;Address&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;BusinessListing&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;BaseModel&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;
    &lt;span class="n"&gt;category&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;
    &lt;span class="n"&gt;rating&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;float&lt;/span&gt;
    &lt;span class="n"&gt;contact&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;Contact&lt;/span&gt;
    &lt;span class="n"&gt;hours&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;dict&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Working with LangChain's Pydantic Output Parser
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;langchain.output_parsers&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;PydanticOutputParser&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;langchain.prompts&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;PromptTemplate&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;langchain.llms&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;OpenAI&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;pydantic&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;BaseModel&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Field&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;AmazonProduct&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;BaseModel&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Field&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;description&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;The product name&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;price&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;float&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Field&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;description&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;The product price in USD&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;rating&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;float&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Field&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;description&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Rating from 1-5&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;reviews&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;int&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Field&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;description&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Number of reviews&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;parser&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;PydanticOutputParser&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pydantic_object&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;AmazonProduct&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;prompt&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;PromptTemplate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;template&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Extract product information from this text:&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;{text}&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;{format_instructions}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;input_variables&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;text&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
    &lt;span class="n"&gt;partial_variables&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;format_instructions&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;parser&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get_format_instructions&lt;/span&gt;&lt;span class="p"&gt;()}&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;model&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;OpenAI&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

&lt;span class="n"&gt;input_text&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"""&lt;/span&gt;&lt;span class="s"&gt;
This amazing laptop is the MacBook Pro 16-inch, priced at $2,399. It has received 
excellent feedback from customers, with a 4.8 star rating based on 3,842 reviews.
&lt;/span&gt;&lt;span class="sh"&gt;"""&lt;/span&gt;

&lt;span class="n"&gt;output&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;model&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;prompt&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;input_text&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="n"&gt;product&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;parser&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;parse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;output&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Conclusion 🎯
&lt;/h2&gt;

&lt;p&gt;Pydantic is more than just a validation library - it's your AI agent's best friend! By defining clear data models and validating inputs and outputs, you can:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Make your AI applications more reliable&lt;/li&gt;
&lt;li&gt;Catch errors early before they cascade into bigger problems&lt;/li&gt;
&lt;li&gt;Guide your models to produce better-structured outputs&lt;/li&gt;
&lt;li&gt;Create self-documenting code that clearly specifies what data you expect&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The next time you're building an AI agent, take the time to define your data models with Pydantic. Your future self (and your users) will thank you!&lt;/p&gt;

&lt;p&gt;Have you used Pydantic with AI projects? Feel free to share your experiences in the comments!&lt;/p&gt;

</description>
      <category>python</category>
      <category>ai</category>
      <category>tutorial</category>
      <category>beginners</category>
    </item>
    <item>
      <title>TypeScript Fundamentals: A Beginner's Guide (2025) ✅</title>
      <dc:creator>Forrester Terry</dc:creator>
      <pubDate>Tue, 07 Jan 2025 02:33:01 +0000</pubDate>
      <link>https://dev.to/sweetpapa/typescript-fundamentals-a-beginners-guide-2025-3ej9</link>
      <guid>https://dev.to/sweetpapa/typescript-fundamentals-a-beginners-guide-2025-3ej9</guid>
      <description>&lt;p&gt;TypeScript has caused endless debates among developers. Some see it as a bureaucratic roadblock to the freedom of JavaScript, while others hail it as a beacon of light in the trenches of loosely typed code. Love it or hate it, TypeScript is here to stay — and once you get to know it, you might just find it’s not a burden but a blessing for your projects.&lt;/p&gt;

&lt;p&gt;In this series we will explore TypeScript and cover the basics -- as well as some tricks and troubleshooting tips.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Introduction
&lt;/h2&gt;

&lt;h3&gt;
  
  
  What is TypeScript?
&lt;/h3&gt;

&lt;p&gt;TypeScript is a statically typed superset of JavaScript that compiles to plain JavaScript. In simpler terms, it’s JavaScript with extra features that help you catch errors early and write better, more maintainable code.&lt;/p&gt;

&lt;p&gt;Think of TypeScript as a friendly assistant who double-checks your work before you submit it. It lets you:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Spot errors while you’re coding, not after you’ve deployed.&lt;/li&gt;
&lt;li&gt;Write code that’s easier to read and understand.&lt;/li&gt;
&lt;li&gt;Scale your projects without losing track of how things connect.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Why Use TypeScript?
&lt;/h3&gt;

&lt;p&gt;Let’s get practical. Why should you care about TypeScript when JavaScript already works?&lt;/p&gt;

&lt;h4&gt;
  
  
  Real Benefits:
&lt;/h4&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Catch Errors Early&lt;/strong&gt;: Avoid common pitfalls, like passing the wrong data type to a function.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;   &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;greet&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
     &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="s2"&gt;`Hello, &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;!`&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
   &lt;span class="p"&gt;}&lt;/span&gt;
   &lt;span class="nf"&gt;greet&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;42&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Error: Argument of type 'number' is not assignable to parameter of type 'string'.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Autocompletion &amp;amp; Documentation&lt;/strong&gt;: Modern editors (like VS Code) provide rich autocomplete suggestions and documentation as you type.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Code Scalability&lt;/strong&gt;: TypeScript’s features shine in larger projects where maintaining consistency is key.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Improved Team Collaboration&lt;/strong&gt;: Clear types make it easier for team members to understand your code at a glance.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;I have found TypeScript to be particularly helpful for planning out bigger apps; understanding what types of data I will be dealing with and what data my functions take/return.&lt;/p&gt;

&lt;h3&gt;
  
  
  Prerequisites
&lt;/h3&gt;

&lt;p&gt;Before diving in, ensure you have basic JavaScript knowledge. You should be familiar with:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Variables and data types (e.g., &lt;code&gt;let&lt;/code&gt;, &lt;code&gt;const&lt;/code&gt;, &lt;code&gt;string&lt;/code&gt;, &lt;code&gt;number&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Functions&lt;/li&gt;
&lt;li&gt;Arrays and objects&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you’re not confident yet, take some time to review JavaScript basics.&lt;/p&gt;




&lt;h2&gt;
  
  
  2. Setting Up Your Environment
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Installing TypeScript
&lt;/h3&gt;

&lt;p&gt;TypeScript is a tool that requires installation to get started. With just a few steps, you can prepare your environment to begin coding in TypeScript. Here’s how to do it:&lt;/p&gt;

&lt;p&gt;To start using TypeScript, you’ll need Node.js installed. Once you have that:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Install TypeScript globally:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   npm &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-g&lt;/span&gt; typescript
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Verify the installation:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   tsc &lt;span class="nt"&gt;--version&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Setting Up VS Code
&lt;/h3&gt;

&lt;p&gt;VS Code is one of the most popular editors for TypeScript development. It provides a range of features and extensions that make coding easier and more efficient. Let’s set it up:&lt;/p&gt;

&lt;p&gt;VS Code is the go-to editor for TypeScript developers. Here’s how to set it up:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Install VS Code: &lt;a href="https://code.visualstudio.com/" rel="noopener noreferrer"&gt;Download here&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Add these helpful extensions:

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;ESLint&lt;/strong&gt;: For linting your TypeScript code.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Prettier&lt;/strong&gt;: For consistent code formatting.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;TypeScript Hero&lt;/strong&gt;: For improved productivity.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Creating Your First TypeScript Project
&lt;/h3&gt;

&lt;p&gt;Getting hands-on is the best way to learn TypeScript. This section guides you through setting up your first project, from creating files to running your code.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Create a new folder for your project and navigate into it:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   &lt;span class="nb"&gt;mkdir &lt;/span&gt;typescript-starter
   &lt;span class="nb"&gt;cd &lt;/span&gt;typescript-starter
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Initialize a new project:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   npm init &lt;span class="nt"&gt;-y&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Add TypeScript:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   npm &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;--save-dev&lt;/span&gt; typescript
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Create a &lt;code&gt;tsconfig.json&lt;/code&gt; file:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   npx tsc &lt;span class="nt"&gt;--init&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Write your first TypeScript file:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"console.log('Hello, TypeScript!');"&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; index.ts
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Compile and run:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   npx tsc index.ts
   node index.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You’ve just written and compiled your first TypeScript program!&lt;/p&gt;




&lt;h2&gt;
  
  
  3. Basic Types Overview
&lt;/h2&gt;

&lt;p&gt;TypeScript’s power lies in its type system. Let’s explore some basic types:&lt;/p&gt;

&lt;h3&gt;
  
  
  Primitive Types
&lt;/h3&gt;

&lt;p&gt;Primitive types are the building blocks of TypeScript’s type system. They include basic data types like strings, numbers, and booleans. Here’s a quick look at how to use them:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;string&lt;/code&gt;&lt;/strong&gt;:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;   &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Alice&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;number&lt;/code&gt;&lt;/strong&gt;:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;   &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;age&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;25&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;boolean&lt;/code&gt;&lt;/strong&gt;:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;   &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;isStudent&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;boolean&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Advanced Types
&lt;/h3&gt;

&lt;p&gt;In addition to primitives, TypeScript supports more complex types like arrays, tuples, and special types like &lt;code&gt;any&lt;/code&gt; and &lt;code&gt;unknown&lt;/code&gt;. These types make your code flexible while maintaining safety.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Arrays&lt;/strong&gt;:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;   &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;scores&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt;&lt;span class="p"&gt;[]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;90&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;85&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;88&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Tuples&lt;/strong&gt;:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;   &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Alice&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;25&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;any&lt;/code&gt;&lt;/strong&gt; (use sparingly):
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;   &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;any&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Could be anything&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;unknown&lt;/code&gt;&lt;/strong&gt; (safer than &lt;code&gt;any&lt;/code&gt;):
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;   &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;unknown&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;void&lt;/code&gt;&lt;/strong&gt; (functions that return nothing):
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;   &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;logMessage&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;message&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="k"&gt;void&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
     &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;message&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
   &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;code&gt;null&lt;/code&gt;&amp;nbsp;and &lt;code&gt;undefined&lt;/code&gt;:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;   &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;something&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
   &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;nothing&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;undefined&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;undefined&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  4. First Steps with Type Annotations
&lt;/h2&gt;

&lt;p&gt;Type Annotations in TypeScript allow developers to specify the type of a variable, parameter, or function return value. This ensures that the code adheres to a defined structure, making it easier to catch errors during development and maintain consistency throughout the project.&lt;/p&gt;

&lt;p&gt;As you write your code as you normally do, take note of the features below that you can integrate&lt;/p&gt;

&lt;h3&gt;
  
  
  Basic Variable Typing
&lt;/h3&gt;

&lt;p&gt;Set types for your variables so that they are always set to the right thing, and the rest of the app understands what they are.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;firstName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Alice&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;age&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;30&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Function Parameter Typing
&lt;/h3&gt;

&lt;p&gt;Similarly, for functions you can define the types for the arguments, as well define the type for the return.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Note the 'number' keywords for each param&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; 
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Return Type Annotations
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Note the 'string' keyword at the end&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;greet&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; 
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="s2"&gt;`Hello, &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;!`&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Practical Example: User Profile
&lt;/h3&gt;

&lt;p&gt;TypeScript allows you to declare your own types to better structure and enforce rules in your code. By using &lt;code&gt;type&lt;/code&gt; or &lt;code&gt;interface&lt;/code&gt;, you can define custom types for objects, functions, or even unions. This not only makes your code more robust but also improves readability and consistency in larger projects.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kr"&gt;interface&lt;/span&gt; &lt;span class="nx"&gt;UserProfile&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;age&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;isActive&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;boolean&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;UserProfile&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Alice&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;age&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;25&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;isActive&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  5. Quick Start with Interfaces
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Basic Syntax
&lt;/h3&gt;

&lt;p&gt;Interfaces in TypeScript define the structure of objects, ensuring they have specific properties and types. This section shows you how to create and use them:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kr"&gt;interface&lt;/span&gt; &lt;span class="nx"&gt;User&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;age&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;User&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Bob&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;age&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;30&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Optional Properties
&lt;/h3&gt;

&lt;p&gt;Sometimes, not all properties in an object are required. TypeScript lets you define optional properties in interfaces to handle such cases gracefully.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kr"&gt;interface&lt;/span&gt; &lt;span class="nx"&gt;Product&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;price&lt;/span&gt;&lt;span class="p"&gt;?:&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;item&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Product&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Notebook&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Readonly Properties
&lt;/h3&gt;

&lt;p&gt;Readonly properties are useful when you want to ensure certain values cannot be changed after they are set. Here’s how to use them in interfaces:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kr"&gt;interface&lt;/span&gt; &lt;span class="nx"&gt;Book&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;readonly&lt;/span&gt; &lt;span class="nx"&gt;title&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;myBook&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Book&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;title&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;TypeScript Handbook&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;
&lt;span class="c1"&gt;// myBook.title = "Another Title"; // Error: Cannot assign to 'title'.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Real-World Example: API Response
&lt;/h3&gt;

&lt;p&gt;Using interfaces to type API responses ensures you handle data from servers safely and effectively. Here’s a practical example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kr"&gt;interface&lt;/span&gt; &lt;span class="nx"&gt;ApiResponse&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;data&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;unknown&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;status&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  6. Practice Project: Building a Simple Todo List
&lt;/h2&gt;

&lt;p&gt;Practice is key to mastering TypeScript. In this project, you’ll create a simple todo list application that leverages the features you’ve learned so far:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Create a &lt;code&gt;Todo&lt;/code&gt; type:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;   &lt;span class="kr"&gt;interface&lt;/span&gt; &lt;span class="nx"&gt;Todo&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
     &lt;span class="nl"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
     &lt;span class="nl"&gt;title&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
     &lt;span class="nl"&gt;completed&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;boolean&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
   &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Build a simple array of todos:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;   &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;todos&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Todo&lt;/span&gt;&lt;span class="p"&gt;[]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
     &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;title&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Learn TypeScript&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;completed&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
   &lt;span class="p"&gt;];&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Add some functions to add todos and mark todos as complete:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;   &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;markAsComplete&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;todo&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Todo&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="nb"&gt;Boolean&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;bUpdated&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;
        &lt;span class="nx"&gt;todos&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;td&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nx"&gt;Todo&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;td&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="nx"&gt;todo&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
                &lt;span class="nx"&gt;bUpdated&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
                &lt;span class="nx"&gt;td&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;completed&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
            &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="p"&gt;})&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;bUpdated&lt;/span&gt;
   &lt;span class="p"&gt;}&lt;/span&gt;

   &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;addToDo&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;todo&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nx"&gt;Todo&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="nb"&gt;Boolean&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="nx"&gt;todos&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;todo&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`Added "&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;todo&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;title&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"" to list!`&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;catch&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Error adding to the todo object!&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
   &lt;span class="p"&gt;}&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  7. Next Steps
&lt;/h2&gt;

&lt;p&gt;That's it for now, hope you enjoyed this tutorial. I will be working on some additional tutorials to dig deeper into useful TypeScript features and use cases.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Coming Up Next&lt;/strong&gt;: Deep dive into TypeScript functions and advanced types.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Resources&lt;/strong&gt;:

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.typescriptlang.org/docs/" rel="noopener noreferrer"&gt;TypeScript Documentation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://codesandbox.io/" rel="noopener noreferrer"&gt;CodeSandbox&lt;/a&gt; for practicing TypeScript online.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;strong&gt;Challenge&lt;/strong&gt;: Create a TypeScript interface for a blog post and use it to type-check a list of blog posts.&lt;/li&gt;

&lt;/ul&gt;

&lt;p&gt;See you next time! &lt;/p&gt;

</description>
      <category>javascript</category>
      <category>typescript</category>
      <category>tutorial</category>
      <category>beginners</category>
    </item>
    <item>
      <title>📦 How to Create, Publish, and Maintain a Node.js Package (in JavaScript and TypeScript)</title>
      <dc:creator>Forrester Terry</dc:creator>
      <pubDate>Mon, 06 Jan 2025 03:59:40 +0000</pubDate>
      <link>https://dev.to/sweetpapa/how-to-create-publish-and-maintain-a-nodejs-package-in-javascript-and-typescript-3jgn</link>
      <guid>https://dev.to/sweetpapa/how-to-create-publish-and-maintain-a-nodejs-package-in-javascript-and-typescript-3jgn</guid>
      <description>&lt;p&gt;Have you ever written a piece of code that could benefit other developers — or even your future self—over and over again? Perhaps it’s a utility function, a library, or a set of reusable tools you find yourself copying and pasting across multiple projects. &lt;/p&gt;

&lt;p&gt;This might be the perfect candidate for an NPM package!&lt;/p&gt;

&lt;p&gt;In this article, we’ll walk step-by-step through creating a simple Node.js package in both &lt;strong&gt;JavaScript&lt;/strong&gt; and &lt;strong&gt;TypeScript&lt;/strong&gt;, setting up best practices such as testing and versioning, and then publishing it to &lt;a href="https://www.npmjs.com/" rel="noopener noreferrer"&gt;npmjs.com&lt;/a&gt;. 🚀&lt;/p&gt;




&lt;h2&gt;
  
  
  Table of Contents
&lt;/h2&gt;

&lt;p&gt;1. Setting Up Your Project&lt;br&gt;&lt;br&gt;
2. Writing Your Package Code&lt;br&gt;&lt;br&gt;
3. Testing Your Package&lt;br&gt;&lt;br&gt;
4. Versioning Best Practices&lt;br&gt;&lt;br&gt;
5. Publishing Your Package&lt;br&gt;&lt;br&gt;
6. Common Features and Best Practices&lt;br&gt;&lt;br&gt;
7. Use Cases&lt;br&gt;&lt;br&gt;
8. Creating Scripts to Automate Common Tasks&lt;/p&gt;


&lt;h2&gt;
  
  
  1. Setting Up Your Project
&lt;/h2&gt;
&lt;h3&gt;
  
  
  1.1 Prerequisites
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Node.js&lt;/strong&gt; (v22.12.0 LTS is recommended as of January 2025, v18 LTS is the oldest version that is still maintained).
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;npm&lt;/strong&gt; (comes bundled with Node).&lt;/li&gt;
&lt;li&gt;A &lt;a href="https://www.npmjs.com/signup" rel="noopener noreferrer"&gt;&lt;strong&gt;npmjs.com&lt;/strong&gt; account&lt;/a&gt; for publishing your package.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  1.2 Initialize Your Project
&lt;/h3&gt;

&lt;p&gt;Create a new directory for your package:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;mkdir &lt;/span&gt;my-awesome-package
&lt;span class="nb"&gt;cd &lt;/span&gt;my-awesome-package
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Initialize a new Node.js project:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm init
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command will ask several questions to help create a &lt;code&gt;package.json&lt;/code&gt; file, the heart of your Node.js package. Key fields to pay attention to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;name&lt;/strong&gt;: The name of your package (must be unique in the npm registry).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;version&lt;/strong&gt;: The version of your package, often starting at &lt;code&gt;1.0.0&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;description&lt;/strong&gt;: A brief explanation of your package.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;entry point&lt;/strong&gt;: The main file (often &lt;code&gt;index.js&lt;/code&gt; or &lt;code&gt;dist/index.js&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;author&lt;/strong&gt;: Your name or organization.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;license&lt;/strong&gt;: The license type (e.g., MIT).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You can skip the Q&amp;amp;A by running &lt;code&gt;npm init -y&lt;/code&gt; to get a default &lt;code&gt;package.json&lt;/code&gt; file.&lt;/p&gt;




&lt;h2&gt;
  
  
  2. Writing Your Package Code
&lt;/h2&gt;

&lt;p&gt;We’ll explore two approaches: &lt;strong&gt;plain JavaScript&lt;/strong&gt; and &lt;strong&gt;TypeScript&lt;/strong&gt;. Choose whichever suits your project needs—or maintain both if you like.&lt;/p&gt;

&lt;h3&gt;
  
  
  2.1 Plain JavaScript Version
&lt;/h3&gt;

&lt;p&gt;Create a file named &lt;code&gt;index.js&lt;/code&gt; in your project root:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// index.js&lt;/span&gt;

&lt;span class="cm"&gt;/**
 * Returns a greeting message
 * @param {string} name - The name to greet
 * @return {string} A greeting message
 */&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;greet&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="s2"&gt;`Hello, &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;!`&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// Export the function as a module&lt;/span&gt;
&lt;span class="nx"&gt;module&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;exports&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;greet&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2.2 TypeScript Version
&lt;/h3&gt;

&lt;h4&gt;
  
  
  2.2.1 Install and Initialize TypeScript
&lt;/h4&gt;

&lt;p&gt;Install Typescript as a development dependency:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;--save-dev&lt;/span&gt; typescript
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Initialize a &lt;code&gt;tsconfig.json&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx tsc &lt;span class="nt"&gt;--init&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  2.2.2 A Recommended tsconfig.json
&lt;/h4&gt;

&lt;p&gt;Replace the generated &lt;code&gt;tsconfig.json&lt;/code&gt; with a configuration tailored for your needs, here we configure for modern Node.js (v22.12.0 LTS):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"compilerOptions"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"target"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"ES2020"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;                        &lt;/span&gt;&lt;span class="err"&gt;//&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;Modern&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;JavaScript&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;features&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"module"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"CommonJS"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;                      &lt;/span&gt;&lt;span class="err"&gt;//&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;Node.js&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;module&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;system&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"rootDir"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"src"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;                          &lt;/span&gt;&lt;span class="err"&gt;//&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;Source&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;files&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;directory&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"outDir"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"dist"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;                          &lt;/span&gt;&lt;span class="err"&gt;//&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;Compiled&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;output&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;directory&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"strict"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;                            &lt;/span&gt;&lt;span class="err"&gt;//&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;Enable&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;all&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;strict&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;type-checking&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;options&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"esModuleInterop"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;                   &lt;/span&gt;&lt;span class="err"&gt;//&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;Better&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;compatibility&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;with&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;CommonJS&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;modules&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"skipLibCheck"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;                      &lt;/span&gt;&lt;span class="err"&gt;//&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;Skip&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;type&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;checking&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;of&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;declaration&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;files&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;for&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;faster&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;builds&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"forceConsistentCasingInFileNames"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="err"&gt;//&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;Enforce&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;consistent&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;file&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;name&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;casing&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"declaration"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;                       &lt;/span&gt;&lt;span class="err"&gt;//&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;Generate&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;.d.ts&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;files&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;for&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;type&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;definitions&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"declarationMap"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="w"&gt;                     &lt;/span&gt;&lt;span class="err"&gt;//&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;Generate&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;source&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;maps&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;for&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;declarations&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"include"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"src/**/*"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"exclude"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"node_modules"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"**/*.test.ts"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This ensures compatibility with modern JavaScript and enforces strict type-checking, improving code quality.&lt;/p&gt;

&lt;h4&gt;
  
  
  2.2.3 Create Your Source File
&lt;/h4&gt;

&lt;p&gt;Create a &lt;code&gt;src&lt;/code&gt; directory and add &lt;code&gt;index.ts&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// src/index.ts&lt;/span&gt;

&lt;span class="cm"&gt;/**
 * Returns a greeting message
 * @param name - The name to greet
 * @returns A greeting message
 */&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;greet&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="s2"&gt;`Hello, &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;!`&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  2.2.4 Update package.json
&lt;/h4&gt;

&lt;p&gt;We need to point &lt;code&gt;main&lt;/code&gt; at the compiled JavaScript file in &lt;code&gt;dist&lt;/code&gt;, and also specify where the type definitions live via the &lt;code&gt;"types"&lt;/code&gt; field. We’ll also add a &lt;code&gt;build&lt;/code&gt; script:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"my-awesome-package"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"version"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"1.0.0"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"description"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"A package that greets the user."&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"main"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"dist/index.js"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"types"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"dist/index.d.ts"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"scripts"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"build"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"tsc"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"test"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"jest"&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"author"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Your Name"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"license"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"MIT"&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;By specifying &lt;code&gt;"types": "dist/index.d.ts"&lt;/code&gt;, consumers of your package automatically get the TypeScript definitions.&lt;/p&gt;

&lt;p&gt;Now, you can compile your TypeScript source by running:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm run build
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  3. Testing Your Package
&lt;/h2&gt;

&lt;p&gt;Testing is not mandatory for publishing but is highly recommended to ensure reliability. We’ll demonstrate using &lt;strong&gt;Jest&lt;/strong&gt; for both JavaScript and TypeScript.&lt;/p&gt;

&lt;h3&gt;
  
  
  3.1 Install Jest
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;--save-dev&lt;/span&gt; jest
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For TypeScript, also install &lt;code&gt;ts-jest&lt;/code&gt; and type definitions:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;--save-dev&lt;/span&gt; ts-jest @types/jest
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  3.2 Configure Jest (TypeScript Only)
&lt;/h3&gt;

&lt;p&gt;Initialize Jest with TypeScript support:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx ts-jest config:init
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This creates a &lt;code&gt;jest.config.js&lt;/code&gt; (or &lt;code&gt;jest.config.ts&lt;/code&gt;) file tailored for TypeScript. Typically, it might look like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// jest.config.js&lt;/span&gt;
&lt;span class="nx"&gt;module&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;exports&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;preset&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;ts-jest&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;testEnvironment&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;node&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  3.3 Write Your Tests
&lt;/h3&gt;

&lt;p&gt;Create a &lt;code&gt;test&lt;/code&gt; directory. Let’s name our test file &lt;code&gt;greet.test.js&lt;/code&gt; or &lt;code&gt;greet.test.ts&lt;/code&gt;, depending on your language choice.&lt;/p&gt;

&lt;h4&gt;
  
  
  3.3.1 JavaScript Test Example
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// test/greet.test.js&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;greet&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;../index&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Using JavaScript's require&lt;/span&gt;

&lt;span class="nf"&gt;test&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;returns a greeting with the given name&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nf"&gt;expect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;greet&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Alice&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)).&lt;/span&gt;&lt;span class="nf"&gt;toBe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Hello, Alice!&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  3.3.2 TypeScript Test Example
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// test/greet.test.ts&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;greet&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;../src/index&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// or '../dist/index' after build&lt;/span&gt;

&lt;span class="nf"&gt;test&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;returns a greeting with the given name&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nf"&gt;expect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;greet&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Alice&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)).&lt;/span&gt;&lt;span class="nf"&gt;toBe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Hello, Alice!&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  3.4 Update package.json for Testing
&lt;/h3&gt;

&lt;p&gt;Ensure your &lt;code&gt;package.json&lt;/code&gt; includes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"scripts"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"build"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"tsc"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"test"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"jest"&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now you can build and test your project via:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm run build
npm &lt;span class="nb"&gt;test&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  4. Versioning Best Practices
&lt;/h2&gt;

&lt;p&gt;Node packages typically follow &lt;a href="https://semver.org/" rel="noopener noreferrer"&gt;SemVer (Semantic Versioning)&lt;/a&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;MAJOR&lt;/strong&gt; for incompatible API changes.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;MINOR&lt;/strong&gt; for adding functionality in a backward-compatible manner.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;PATCH&lt;/strong&gt; for backward-compatible bug fixes.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example: &lt;code&gt;1.0.0&lt;/code&gt; (Major.Minor.Patch)&lt;/p&gt;

&lt;p&gt;To increment your package version (and create a Git tag if you’re using Git):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm version patch   &lt;span class="c"&gt;# e.g., 1.0.0 -&amp;gt; 1.0.1&lt;/span&gt;
npm version minor   &lt;span class="c"&gt;# e.g., 1.0.1 -&amp;gt; 1.1.0&lt;/span&gt;
npm version major   &lt;span class="c"&gt;# e.g., 1.1.0 -&amp;gt; 2.0.0&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  5. Publishing Your Package
&lt;/h2&gt;

&lt;h3&gt;
  
  
  5.1 Log in to npm
&lt;/h3&gt;

&lt;p&gt;Before you can publish, authenticate with npm:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm login
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Enter your credentials and/or token. If you haven’t created an account yet, &lt;a href="https://www.npmjs.com/signup" rel="noopener noreferrer"&gt;sign up here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Alternatively, you can setup your &lt;code&gt;.npmrc&lt;/code&gt; to handle the authentications:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; //registry.npmjs.org/:_authToken&lt;span class="o"&gt;=&lt;/span&gt;MY_TOKEN &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; ~/.npmrc
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can change the registry path as needed, depending on your NPM repository instance. For instance, for GitHub you may do:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; //npm.pkg.github.com/:_authToken&lt;span class="o"&gt;=&lt;/span&gt;MY_TOKEN &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; ~/.npmrc
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  5.2 Publish
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;For a plain JavaScript package&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm publish
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;For a TypeScript package&lt;/strong&gt;, build your code before publishing:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm run build
npm publish
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Your package is now live on the npm registry, and anyone can install it with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install &lt;/span&gt;my-awesome-package
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If your package name is scoped (e.g., &lt;code&gt;@your-scope/my-awesome-package&lt;/code&gt;), you might need:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm publish &lt;span class="nt"&gt;--access&lt;/span&gt; public
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;(&lt;code&gt;--access public&lt;/code&gt; is required for scoped packages to be publicly available.)&lt;/p&gt;




&lt;h2&gt;
  
  
  6. Common Features and Best Practices
&lt;/h2&gt;

&lt;h3&gt;
  
  
  6.1 README.md
&lt;/h3&gt;

&lt;p&gt;A clear &lt;code&gt;README.md&lt;/code&gt; is essential for explaining your package. Include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Installation Instructions&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;  npm &lt;span class="nb"&gt;install &lt;/span&gt;my-awesome-package
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Basic Usage&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;  &lt;span class="c1"&gt;// JavaScript:&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;greet&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;my-awesome-package&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;greet&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Alice&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt; &lt;span class="c1"&gt;// Hello, Alice!&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;  &lt;span class="c1"&gt;// TypeScript:&lt;/span&gt;
  &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;greet&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;my-awesome-package&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;greet&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Alice&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt; &lt;span class="c1"&gt;// Hello, Alice!&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Advanced Examples&lt;/strong&gt;: Show more use cases, configuration, or integration details.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;API Documentation&lt;/strong&gt;: If your package has multiple methods or classes, document them thoroughly.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  6.2 LICENSE
&lt;/h3&gt;

&lt;p&gt;Including a license clarifies how your package can be used. Define it in:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;A &lt;code&gt;LICENSE&lt;/code&gt; file at the root.
&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;license&lt;/code&gt; field in &lt;code&gt;package.json&lt;/code&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  6.3 GitHub Repository
&lt;/h3&gt;

&lt;p&gt;While not strictly required, hosting your package on a platform like GitHub helps with:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Collaboration&lt;/strong&gt; (issues, pull requests)
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Version Control&lt;/strong&gt; (Git tags, branches)
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Automated CI&lt;/strong&gt; (running tests on each commit)&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  6.4 Linting
&lt;/h3&gt;

&lt;p&gt;Use a linter like &lt;a href="https://eslint.org/" rel="noopener noreferrer"&gt;ESLint&lt;/a&gt; for consistent coding standards.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;--save-dev&lt;/span&gt; eslint
npx eslint &lt;span class="nt"&gt;--init&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Configure your lint rules, then run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm run lint
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  6.5 Continuous Integration (CI)
&lt;/h3&gt;

&lt;p&gt;For open-source or team projects, consider GitHub Actions, Travis CI, or similar. This ensures tests run automatically on every commit, increasing confidence and catching issues early.&lt;/p&gt;

&lt;h3&gt;
  
  
  6.6 Adding Dependencies and Managing Dependency Files
&lt;/h3&gt;

&lt;p&gt;As your package grows, you might need to incorporate other libraries or tools to enhance its functionality. Managing dependencies effectively ensures that your package remains robust, maintainable, and easy for others to use.&lt;/p&gt;

&lt;h4&gt;
  
  
  6.6.1. Adding Dependencies
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Dependencies&lt;/strong&gt; are packages required for your package to run correctly. &lt;strong&gt;DevDependencies&lt;/strong&gt; are packages needed only during development, such as testing frameworks or build tools.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;To add a runtime dependency&lt;/strong&gt;:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;  npm &lt;span class="nb"&gt;install &lt;/span&gt;lodash
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command adds the &lt;code&gt;lodash&lt;/code&gt; library as a dependency and updates your &lt;code&gt;package.json&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"dependencies"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"lodash"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"^4.17.21"&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;To add a development dependency&lt;/strong&gt;:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;  npm &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;--save-dev&lt;/span&gt; eslint
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This adds &lt;code&gt;eslint&lt;/code&gt; as a devDependency:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"devDependencies"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"eslint"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"^8.0.0"&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  6.6.2. Managing Dependency Files
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;code&gt;package.json&lt;/code&gt;&lt;/strong&gt;: This file lists all your dependencies and devDependencies. Ensure that all necessary packages are correctly listed to avoid missing dependencies during installation.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;code&gt;package-lock.json&lt;/code&gt;&lt;/strong&gt;: Automatically generated when you install dependencies, this file locks the versions of your dependencies to ensure consistent installations across different environments. &lt;strong&gt;Do not manually edit this file&lt;/strong&gt;; instead, let npm manage it.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  6.6.3. Best Practices
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Keep Dependencies Updated&lt;/strong&gt;: Regularly update your dependencies to incorporate the latest features and security patches. You can use tools like &lt;a href="https://www.npmjs.com/package/npm-check-updates" rel="noopener noreferrer"&gt;npm-check-updates&lt;/a&gt; to assist with this.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;  npm &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-g&lt;/span&gt; npm-check-updates
  ncu &lt;span class="nt"&gt;-u&lt;/span&gt;
  npm &lt;span class="nb"&gt;install&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Minimize Dependencies&lt;/strong&gt;: Only include packages that are essential for your package’s functionality. Fewer dependencies reduce the risk of conflicts and vulnerabilities.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Use Peer Dependencies When Appropriate&lt;/strong&gt;: If your package is a plugin or extension that relies on a host package (like React), specify it as a peer dependency to avoid version conflicts.&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;  npm &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;--save-peer&lt;/span&gt; react
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Update your &lt;code&gt;package.json&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"peerDependencies"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"react"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"^17.0.0"&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  6.6.4. Example: Adding a Dependency
&lt;/h4&gt;

&lt;p&gt;Suppose you want to use &lt;code&gt;axios&lt;/code&gt; for making HTTP requests in your package.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Install axios as a dependency&lt;/strong&gt;:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   npm &lt;span class="nb"&gt;install &lt;/span&gt;axios
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Use axios in your code&lt;/strong&gt;:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;   &lt;span class="c1"&gt;// src/index.ts&lt;/span&gt;
   &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;axios&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;axios&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

   &lt;span class="cm"&gt;/**
    * Fetches user data from an API
    * @param userId - The ID of the user
    * @returns User data
    */&lt;/span&gt;
   &lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;fetchUserData&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;userId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="nb"&gt;Promise&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kr"&gt;any&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
     &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;axios&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`https://api.example.com/users/&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;userId&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
     &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
   &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  7. Use Cases
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Utility Packages&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;E.g., date-formatting libraries to simplify working with dates.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;UI Components&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;E.g., a set of React or Vue components published as a standalone package.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;CLI Tools&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;E.g., command-line utilities for scaffolding projects or automating tasks.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Libraries for APIs&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;E.g., wrappers for third-party APIs or microservices, making them easy to integrate with Node.js.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  8. Creating Scripts to Automate Common Tasks
&lt;/h2&gt;

&lt;p&gt;To streamline your development workflow, it's beneficial to define custom scripts in your &lt;code&gt;package.json&lt;/code&gt;. These scripts can handle tasks like building, testing, deploying, and versioning your package with simple commands.&lt;/p&gt;

&lt;h3&gt;
  
  
  8.1. Benefits of Custom Scripts
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Automation&lt;/strong&gt;: Reduce manual steps by automating build and deployment processes.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Consistency&lt;/strong&gt;: Ensure that tasks are performed the same way every time.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Modularity&lt;/strong&gt;: Create reusable scripts that can be combined for complex workflows.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Efficiency&lt;/strong&gt;: Save time by chaining multiple commands into a single script.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  8.2. Example: Deploying to Development and Production
&lt;/h3&gt;

&lt;p&gt;Let's create two deployment scripts: &lt;code&gt;deploy:dev&lt;/code&gt; for development environments and &lt;code&gt;deploy:prod&lt;/code&gt; for production. These scripts will handle tasks such as building the project, tagging the Git repository, versioning, and deploying the package.&lt;/p&gt;

&lt;h4&gt;
  
  
  8.2.1. Defining the Scripts in &lt;code&gt;package.json&lt;/code&gt;
&lt;/h4&gt;

&lt;p&gt;Open your &lt;code&gt;package.json&lt;/code&gt; and add the following scripts under the &lt;code&gt;"scripts"&lt;/code&gt; section:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"scripts"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"build"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"tsc"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"test"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"jest"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"version"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"npm version patch"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"tag:dev"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"git tag -a v$(node -p &lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;require('./package.json').version&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;) -m &lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;Dev deployment v$(node -p &lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;require('./package.json').version&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;)&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"deploy:dev"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"npm run build &amp;amp;&amp;amp; npm run test &amp;amp;&amp;amp; npm run version &amp;amp;&amp;amp; npm run tag:dev &amp;amp;&amp;amp; git push &amp;amp;&amp;amp; git push --tags &amp;amp;&amp;amp; npm publish --tag dev"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"tag:prod"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"git tag -a v$(node -p &lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;require('./package.json').version&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;) -m &lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;Production deployment v$(node -p &lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;require('./package.json').version&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;)&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"deploy:prod"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"npm run build &amp;amp;&amp;amp; npm run test &amp;amp;&amp;amp; npm run version &amp;amp;&amp;amp; npm run tag:prod &amp;amp;&amp;amp; git push &amp;amp;&amp;amp; git push --tags &amp;amp;&amp;amp; npm publish"&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  8.2.2. Breakdown of the Scripts
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;build&lt;/code&gt;&lt;/strong&gt;: Compiles the TypeScript code into JavaScript using the TypeScript compiler.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;test&lt;/code&gt;&lt;/strong&gt;: Runs the Jest test suite to ensure your package is working correctly.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;version&lt;/code&gt;&lt;/strong&gt;: Increments the patch version in &lt;code&gt;package.json&lt;/code&gt; following Semantic Versioning.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;tag:dev&lt;/code&gt; / &lt;code&gt;tag:prod&lt;/code&gt;&lt;/strong&gt;: Creates a Git tag corresponding to the current version for development or production deployments.&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;&lt;code&gt;deploy:dev&lt;/code&gt;&lt;/strong&gt;: &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Builds&lt;/strong&gt; the project.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Tests&lt;/strong&gt; the build.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Versions&lt;/strong&gt; the package.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Tags&lt;/strong&gt; the commit for a development deployment.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Pushes&lt;/strong&gt; the commits and tags to the remote repository.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Publishes&lt;/strong&gt; the package to npm with the &lt;code&gt;dev&lt;/code&gt; tag.&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;code&gt;deploy:prod&lt;/code&gt;&lt;/strong&gt;: Similar to &lt;code&gt;deploy:dev&lt;/code&gt; but publishes the package without a tag, making it the latest stable release.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  8.3. Running the Deployment Scripts
&lt;/h3&gt;

&lt;p&gt;With the scripts defined, deploying becomes straightforward:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Deploy to Development&lt;/strong&gt;:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;  npm run deploy:dev
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command will build your project, run tests, increment the patch version, create a Git tag, push changes, and publish the package with the &lt;code&gt;dev&lt;/code&gt; tag.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Deploy to Production&lt;/strong&gt;:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;  npm run deploy:prod
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command performs the same steps as &lt;code&gt;deploy:dev&lt;/code&gt; but publishes the package as the latest stable version without an additional tag.&lt;/p&gt;

&lt;h3&gt;
  
  
  8.4. Making Scripts Modular
&lt;/h3&gt;

&lt;p&gt;By breaking down tasks into smaller, reusable scripts (like &lt;code&gt;build&lt;/code&gt;, &lt;code&gt;test&lt;/code&gt;, &lt;code&gt;version&lt;/code&gt;, and tagging), you can compose complex workflows easily. This modularity allows you to maintain and update individual steps without affecting the entire deployment process.&lt;/p&gt;

&lt;p&gt;For example, if you need to change how the project is built, you only need to update the &lt;code&gt;build&lt;/code&gt; script without modifying the deployment scripts.&lt;/p&gt;

&lt;h3&gt;
  
  
  8.5. Additional Automation Tips
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Pre/Post Hooks&lt;/strong&gt;: Utilize npm's pre and post script hooks to run tasks automatically before or after specific scripts. For instance, you can add a &lt;code&gt;prepublishOnly&lt;/code&gt; script to ensure tests pass before publishing.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"scripts"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"prepublishOnly"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"npm run test &amp;amp;&amp;amp; npm run build"&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Environment Variables&lt;/strong&gt;: Manage different environments (development, staging, production) by using environment variables within your scripts or leveraging packages like &lt;a href="https://www.npmjs.com/package/cross-env" rel="noopener noreferrer"&gt;cross-env&lt;/a&gt; for cross-platform compatibility.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Error Handling&lt;/strong&gt;: Incorporate error handling in your scripts to halt the process if a critical step fails, ensuring that incomplete or faulty deployments do not occur.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  In Review
&lt;/h2&gt;

&lt;p&gt;Publishing an NPM package may feel daunting, but the fundamentals are straightforward:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Initialize your project with &lt;code&gt;npm init&lt;/code&gt;.
&lt;/li&gt;
&lt;li&gt;Write your code in either JavaScript or TypeScript (v5.7.2 recommended).
&lt;/li&gt;
&lt;li&gt;Add tests to ensure your package remains reliable.
&lt;/li&gt;
&lt;li&gt;Follow &lt;a href="https://semver.org/" rel="noopener noreferrer"&gt;SemVer&lt;/a&gt; for version management.
&lt;/li&gt;
&lt;li&gt;Publish your package with &lt;code&gt;npm publish&lt;/code&gt;.
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;By following these best practices you’ll have a package that is reliable, easy to maintain, and simple for others to consume. 💻  &lt;/p&gt;

</description>
      <category>javascript</category>
      <category>typescript</category>
      <category>npm</category>
      <category>beginners</category>
    </item>
  </channel>
</rss>
