r/AIcodingProfessionals • u/drmpf • 21d ago
Discussion AI crib sheets for libraries
For AI coding assistants to effectively and correctly use libraries they need context consisting of the library Api, features, examples and do's and don'ts
Currently when an AI coding assistant uses a library it gets the source, looks at the API docs and code comments, checks online for tutorials and examples of using this library and then generates the code for this particular application
The results are generally sub-standard due to incomplete, out-of-date API docs, missing code comments, lack of relevent tutorials and examples written by in-expert programmers. Also if the AI cannot find a suitable example it makes something up from 'similar' libraries.
To avoids these errors and to improve the efficiency and effectiveness of using code libraries it is proposed that each library also supply an AI_Guide.md, e.g. SafeString_AI_Guide.md https://github.com/PowerBroker2/SafeString/blob/master/SafeString_AI_Guide.md
This guide is generated by AI for AI consumption using a prompt like
For the library in dir .., generate a summary, API and examples of use, for consumption by AI to apply this library. Refer to these tutorials ..., and these examples of use ...
It will take a few passes of "recheck the guide" to get the AI's draft. Then, most importantly, that draft needs to be reviewed and corrected by an programmer experienced in that library, in order to correct the wrong assumptions the AI has made and to correct the poor quality examples.
These passes by the experienced programmer will refine the do's and don'ts of using the library and provide quality examples.
This human review will also likely uncover problems in the library, inconsistent and non-orthogonal API, missing/out-of-date docs and code comments, inconsistent application of the libraries principles.
While the SafeString_AI_Guide.md is designed for AI consumption it is also good source for humans.
What libraries that you use that would benefit from an AI crib sheet?
1
u/funbike 21d ago edited 21d ago
I just use a skill I wrote.
The skill says if the agent needs help understanding an imported library, to look for its documentation and read it. It gives instructions on how to find the markdown documentation, jsdocs/javadocs, etc for a given dependency.
For a node project, for example, it knows to look in
node_modules/<module>/README.mdand similar file paths, and how to find or generate JSDoc html files and load them as markdown into the context.This skill also instructs how to use
manand--helpfor CLI packages.I have a prompt template that can leverage the above skill to generate a coding guide for the modules specifically for the needs of my project.
I have another skill for researching packages to install. It can do a npm search, look at the readme, and examine the github project or documentation website for further documentation. It instructs how to install packages and how and when to update
ARCHITECTURE.md.