<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/why-your-ai-generates-crap-code---and-how-to-fix-it-alfu7glh2" -->

---
title: Why Your AI Generates Crap Code - And How to Fix It
description: A walkthrough of why AI coding agents produce poor code and how to fix it by properly structuring configuration files. Covers the hierarchy of context sent to...
canonical: https://daily.dev/posts/why-your-ai-generates-crap-code---and-how-to-fix-it-alfu7glh2
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Why Your AI Generates Crap Code - And How to Fix It | daily.dev
og:description: A walkthrough of why AI coding agents produce poor code and how to fix it by properly structuring configuration files. Covers the hierarchy of context sent to...
og:url: https://daily.dev/posts/why-your-ai-generates-crap-code---and-how-to-fix-it-alfu7glh2
og:image: https://api.daily.dev/og/posts/aLfu7gLh2.png
og:image:alt: Why Your AI Generates Crap Code - And How to Fix It
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Why Your AI Generates Crap Code - And How to Fix It

**[Web Dev Simplified](https://daily.dev/sources/wds)** · 23 min read · 10 upvotes · 1 comments

## Summary

A walkthrough of why AI coding agents produce poor code and how to fix it by properly structuring configuration files. Covers the hierarchy of context sent to an AI (system prompt, agents.md/claude.md, skills, documentation, codebase, prompt) and shows real examples from Codex, Airflow, and VS Code where agents.md files are bloated with thousands of tokens of irrelevant information. Recommends keeping agents.md minimal with a short project description and links to separate documentation files for specifics like CSS, API, or TypeScript conventions, only loaded when relevant. Also explains using symbolic links to keep claude.md and agents.md in sync, nesting agents.md files in monorepos for folder-specific context, and using 'skills' (downloadable markdown instruction sets via npx skills add or skills.sh) for one-off, specific tasks like authentication, keeping the main agents.md file lean.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://www.youtube.com/watch?v=jojMVmRZABw>

## Questions this post answers

### How should I structure my agents.md file so my AI coding agent doesn't produce bad code?

Keep agents.md as small as possible: a one or two sentence project description, the package manager if non-standard, a high-level repository layout, and any unusual scripts. Instead of embedding detailed conventions for CSS, API, React, or TypeScript directly, link out to separate documentation files that only get loaded when relevant, since the entire agents.md is sent with every single request.

_Developers refining their agents.md setup can find more practical AI workflow breakdowns on daily.dev._

### What is the difference between agents.md, claude.md, and gemini.md files for AI coding agents?

They serve the identical purpose but different tools require different filenames: Claude Code requires claude.md, Gemini-based tools may look for gemini.md, and other agents use agents.md. Because agents often edit whichever file is present, it's recommended to make claude.md a symbolic link to agents.md (using ln -s on Linux/Mac or mklink /d on Windows) so both stay in sync automatically.

_Anyone juggling multiple AI coding tools can track configuration quirks like this via daily.dev._

### When should I use a skill instead of putting instructions in agents.md for an AI coding agent?

Use agents.md for general information that applies to almost every request, like coding conventions or folder structure, and use a skill for specific, one-off tasks like authentication that aren't touched often. Skills are markdown files installed via npx skills add and are only loaded into context when the agent determines they're needed, unlike agents.md which is sent with every single request in full.

_Developers deciding between skills and agents.md for their AI setup can find similar workflow comparisons on daily.dev._

## Community discussion

Top comments from developers on daily.dev.

**@73m3r007** · 2 upvotes

> Super video!

## Similar posts on daily.dev

- [How to Manage Context Files in Your Codebase and Get Better Output From AI Coding Agents](https://daily.dev/posts/how-to-manage-context-files-in-your-codebase-and-get-better-output-from-ai-coding-agents-jmjpmaeus) · freeCodeCamp · 2 upvotes · 1 comments
- [How to Optimize Your AI Coding Agent Context](https://daily.dev/posts/how-to-optimize-your-ai-coding-agent-context-ytptgsacl) · Towards Data Science · 2 upvotes · 0 comments

---

Tags: [#llm](https://daily.dev/tags/llm), [#ai-agents](https://daily.dev/tags/ai-agents), [#claude-code](https://daily.dev/tags/claude-code), [#prompt-engineering](https://daily.dev/tags/prompt-engineering)

[View this post on daily.dev](https://daily.dev/posts/why-your-ai-generates-crap-code---and-how-to-fix-it-alfu7glh2)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Why Your AI Generates Crap Code - And How to Fix It","url":"https://daily.dev/posts/why-your-ai-generates-crap-code---and-how-to-fix-it-alfu7glh2","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/why-your-ai-generates-crap-code---and-how-to-fix-it-alfu7glh2"},"datePublished":"2026-09-15T20:16:02.550Z","dateModified":"2026-10-15T02:22:54.223Z","description":"A walkthrough of why AI coding agents produce poor code and how to fix it by properly structuring configuration files. Covers the hierarchy of context sent to...","image":"https://i.ytimg.com/vi/jojMVmRZABw/sddefault.jpg","thumbnailUrl":"https://i.ytimg.com/vi/jojMVmRZABw/sddefault.jpg","isAccessibleForFree":true,"articleSection":"Web Dev Simplified","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Web Dev Simplified","logo":"https://media.daily.dev/image/upload/s--dXRQOCB9--/f_auto/v1718347713/logos/wds","url":"https://daily.dev/sources/wds"},"commentCount":1,"discussionUrl":"https://daily.dev/posts/why-your-ai-generates-crap-code---and-how-to-fix-it-alfu7glh2","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":10},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":1}],"keywords":"llm,ai-agents,claude-code,prompt-engineering","timeRequired":"PT23M","video":{"@type":"VideoObject","name":"Why Your AI Generates Crap Code - And How to Fix It","description":"A walkthrough of why AI coding agents produce poor code and how to fix it by properly structuring configuration files. Covers the hierarchy of context sent to...","thumbnailUrl":"https://i.ytimg.com/vi/jojMVmRZABw/sddefault.jpg","uploadDate":"2026-09-15T20:16:02.550Z","duration":"PT23M","url":"https://api.daily.dev/r/aLfu7gLh2","embedUrl":"https://www.youtube.com/embed/jojMVmRZABw"}}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Web Dev Simplified","item":"https://daily.dev/sources/wds"},{"@type":"ListItem","position":3,"name":"Why Your AI Generates Crap Code - And How to Fix It"}]}
{"@context":"https://schema.org","@type":"WebPage","@id":"https://daily.dev/posts/why-your-ai-generates-crap-code---and-how-to-fix-it-alfu7glh2","comment":[{"@type":"Comment","text":"Super video!","datePublished":"2026-09-16T10:40:50.903Z","url":"https://daily.dev/posts/aLfu7gLh2#c-wYALcpd3X","author":{"@type":"Person","name":"Petar Kolev","url":"https://daily.dev/73m3r007","image":"https://lh3.googleusercontent.com/a/ALm5wu2jEq5qaVO1BG0L8GwAdGz9J_o38qWtlBBuxZEymQ=s96-c"},"interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":2}}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/why-your-ai-generates-crap-code---and-how-to-fix-it-alfu7glh2#faq","mainEntity":[{"@type":"Question","name":"How should I structure my agents.md file so my AI coding agent doesn't produce bad code?","acceptedAnswer":{"@type":"Answer","text":"Keep agents.md as small as possible: a one or two sentence project description, the package manager if non-standard, a high-level repository layout, and any unusual scripts. Instead of embedding detailed conventions for CSS, API, React, or TypeScript directly, link out to separate documentation files that only get loaded when relevant, since the entire agents.md is sent with every single request. Developers refining their agents.md setup can find more practical AI workflow breakdowns on daily.dev."}},{"@type":"Question","name":"What is the difference between agents.md, claude.md, and gemini.md files for AI coding agents?","acceptedAnswer":{"@type":"Answer","text":"They serve the identical purpose but different tools require different filenames: Claude Code requires claude.md, Gemini-based tools may look for gemini.md, and other agents use agents.md. Because agents often edit whichever file is present, it's recommended to make claude.md a symbolic link to agents.md (using ln -s on Linux/Mac or mklink /d on Windows) so both stay in sync automatically. Anyone juggling multiple AI coding tools can track configuration quirks like this via daily.dev."}},{"@type":"Question","name":"When should I use a skill instead of putting instructions in agents.md for an AI coding agent?","acceptedAnswer":{"@type":"Answer","text":"Use agents.md for general information that applies to almost every request, like coding conventions or folder structure, and use a skill for specific, one-off tasks like authentication that aren't touched often. Skills are markdown files installed via npx skills add and are only loaded into context when the agent determines they're needed, unlike agents.md which is sent with every single request in full. Developers deciding between skills and agents.md for their AI setup can find similar workflow comparisons on daily.dev."}}]}
```

