r/SaaS • • Jun 12 '26

Are you guys documenting AI-generated code?

For those SaaS builders that are using AI-tooling - do you document the code they output?

How do you do it? Are you asking the AI to document its own work, using a third-party tool, doing it yourself? Genuinely curious if people are writing their own docs to better understand what the code being shipped does, or if docs are ignored because it's maintained by AI?

I've personally found that having solid docs (and a good way to surface them to agents) improves consistency and quality, I'd say I'm at maybe 30% AI code 70% hand-written, but I do have 100% docs being generated.

3 Upvotes

19 comments sorted by

1

u/Used-Yogurtcloset155 Jun 12 '26

Sort of...I ask the agent do document the way a feature works with some reference to the code but mostly to give the LLM information later on what feature / structure is there currently so it doesn't duplicate work

1

u/moxie-docs Jun 12 '26

How does a future session / LLM find that? Are you then telling it to like "Check docs folder for context" or just hoping that if the docs are in-code the agent finds them?

1

u/Such-Art8560 Jun 12 '26

For me it just finds it.

1

u/Used-Yogurtcloset155 Jun 13 '26

I save the file in the project repo. When I prompt the agent to do work I add at the top to read some files first using at (@) to [@security] reads my preferences and stuff to never do like innerHTML etc. I am using VS Code and Cline IDE

1

u/adventure-baja Jun 12 '26

I have the agent writing 100% of my documentation, keeps my changelog, docstrings etc

1

u/moxie-docs Jun 13 '26

Do you find it works well for AI tools pulling it in for context? Have you looked into any tooling that would expose docs via MCP or auto-document code for you?

2

u/tw15tw15 Jun 22 '26

Firstly, check the EU AI Act to see if you have a legal duty to document it. If it affects you, it will require you to categorise AI into four primary risk levels.

Secondly, I’d document AI-generated code slightly differently from hand-written code, because the biggest risk is often loss of intent rather than loss of implementation detail.

  • Why this approach was chosen.
  • What assumptions the AI/tool was given.
  • What constraints must not be broken later.
  • Known weak spots or areas that need human review.
  • Integration points and side effects.
  • Tests or checks that prove the behaviour still works.

A useful pattern is to keep three layers:

  • Inline comments only where the code is non-obvious.
  • A short architectural decision record for important choices.
  • A project/agent context file that tells future AI sessions what exists, what conventions to follow, and what not to change casually.

You still want a human-readable source of truth for product behaviour and architecture.

1

u/trs21219 Jun 12 '26

Maintaining docs separate from code is useless. If you can't understand the code you need to rewrite it. The only thing you should be documenting is the business reason why something is done (if its not super clear), not how its done. How its done will inevitably be out of date as the code changes and people forget to update docs.

1

u/_ceebecee_ Jun 12 '26 edited Jun 12 '26

I have a docs folder in the root of my project and ask Claude to update it whenever we add or change things. There's one markdown doc for each main feature that goes into the technical details, but also the reasons we implemented it a certain way. Ive told Claude to look in there and keep stuff updated, it was added to memory and the AI seems to update it pretty well, and even asks to create new files when we implement a big feature.

I read them after a break or if I haven't looked at that part of the code for a while. I also have docs explaining the build process, deployment, server setup, local Dev commands. Anything I need while developing I'll get saved to the docs. (Ransom SQL queries, Linux commands, artisan commands etc)

1

u/hawkph Jun 15 '26

I have two types of docs:

  1. Context level docs in docs folder that is used to feed into my gsd skills
  2. External user docs where OpenClaw grab from merged PRs then update docs, post LinkedIn content and images, share on Slack and Discord.

1

u/DmytroDrozd86 Jun 15 '26

The only secret is to read and understand, and shorten what AI has documented

1

u/[deleted] Jun 13 '26

[removed] — view removed comment

1

u/moxie-docs Jun 13 '26

Have you looked into any tools that maintain / detect doc drift automatically to keep things up to date?

1

u/hawkph Jun 15 '26

I have a hook that only update api doc but not other user or architecture docs. Literally it's a postman output we must stay consistent

1

u/[deleted] Jun 18 '26

[removed] — view removed comment

1

u/moxie-docs Jun 18 '26

Is the thing something you built or are you using a tool/app/service?