{"id":7082,"date":"2025-09-27T02:23:16","date_gmt":"2025-09-27T02:23:16","guid":{"rendered":"https:\/\/techtrendfeed.com\/?p=7082"},"modified":"2025-09-27T02:23:16","modified_gmt":"2025-09-27T02:23:16","slug":"anchoring-ai-to-a-reference-utility","status":"publish","type":"post","link":"https:\/\/techtrendfeed.com\/?p=7082","title":{"rendered":"Anchoring AI to a reference utility"},"content":{"rendered":"<p> <br \/>\n<\/p>\n<div>\n<p>Service templates are a typical constructing block within the \u201cgolden paths\u201d organisations construct for his or her engineering groups, to make it straightforward to do the correct factor. The templates are imagined to be the function fashions for all of the companies within the organisation, all the time representing the hottest coding patterns and requirements.<\/p>\n<p>One of many challenges with service templates although is that when a crew instantiated a service with one, it\u2019s tedious to feed template updates again to these companies. Can GenAI assist with that?<\/p>\n<h2 id=\"reference-application-as-sample-provider\">Reference utility as pattern supplier<\/h2>\n<p>As half of a bigger experiment that I just lately wrote about <a rel=\"nofollow\" target=\"_blank\" href=\"https:\/\/martinfowler.com\/articles\/pushing-ai-autonomy.html\">right here<\/a>, I created an MCP server that offers a coding assistant entry to coding samples for typical patterns. In my case, this was for a Spring Boot net utility, the place the patterns had been repository, service and controller courses. It&#8217;s a properly established prompting follow at this level that offering LLMs with examples of the outputs that we would like results in higher outcomes. To place \u201coffering examples\u201d into fancier phrases: That is additionally known as \u201c<a rel=\"nofollow\" target=\"_blank\" href=\"https:\/\/martinfowler.com\/articles\/pushing-ai-autonomy.html\">few-shot prompting<\/a>\u201d, or \u201cin-context studying\u201d.<\/p>\n<p>Once I began working with code samples in prompts, I shortly realised how tedious this was, as a result of I used to be working in a pure language markdown file. It felt a little bit bit like writing my first Java exams at college, in pencil: You have got know concept if the code you\u2019re writing really compiles. And what\u2019s extra, in the event you\u2019re creating prompts for a number of coding patterns, you wish to hold them according to one another. Sustaining code samples in a reference utility challenge you can compile and run (like a service template) makes it rather a lot simpler to offer AI with compilable, constant samples.<\/p>\n<p class=\"full\"><img decoding=\"async\" src=\"https:\/\/martinfowler.com\/articles\/exploring-gen-ai\/drift-commit-example.png\" alt=\"Screenshot showing a git commit diff that introduces @Slf4j to a controller, and log.debug statements to each controller method\" \/><\/p>\n<h2 id=\"detect-drift-from-the-reference-application\">Detect drift from the reference utility<\/h2>\n<p>Now again to the issue assertion I discussed at the start: As soon as code is generated (be that with AI, or with a service template), after which additional prolonged and maintained, codebases usually drift away from the function mannequin of the reference utility.<\/p>\n<p>So in a second step, I puzzled how we&#8217;d use this strategy to do a \u201ccode sample drift detection\u201d between the codebase and the reference utility. I examined this with a comparatively easy instance, I added a logger and log.debug statements to the reference utility\u2019s controller courses:<\/p>\n<p class=\"full\"><img decoding=\"async\" src=\"https:\/\/martinfowler.com\/articles\/exploring-gen-ai\/drift-mcp-server-samples.png\" alt=\"Screenshot of a git commit diff in the reference application, showing a controller with an added @Slf4j annotation, and a log.debug statement in one of the endpoint mappings.\" \/><\/p>\n<p>Then I expanded the MCP server to offer entry to the git commits within the reference utility. Asking the agent to first search for the precise modifications within the reference offers me some management over the scope of the drift detection, I can use the commits to speak to AI precisely what sort of drift I\u2019m concerned with. Earlier than I launched this, once I simply requested AI to match the reference controllers with the prevailing controllers, it went a bit overboard with a number of irrelevant comparisons, and I noticed this commit-scoping strategy have  affect.<\/p>\n<p class=\"full\"><img decoding=\"async\" src=\"https:\/\/martinfowler.com\/articles\/exploring-gen-ai\/drift-mcp-server-commits.png\" alt=\"An expanded version of the previous diagram, this time showing the setup for the drift detection. The prompt asks the agent to find latest changes, the agent gets the latest commit from the reference application, via MCP server. The agent then looks at the diff and uses it to analyse the target application, and to create a drift report. In a second step, the user can then ask the agent to write code that closes the gaps identified in the report.\" \/><\/p>\n<p>In step one, I simply requested AI to generate a report for me that recognized all of the drift, so I might assessment and edit that report, e.g. take away findings that had been irrelevant. Within the second step, I requested AI to take the report and write code that closes the gaps recognized.<\/p>\n<h3 id=\"when-is-ai-bringing-something-new-to-the-table\">When is AI bringing one thing new to the desk?<\/h3>\n<p>A factor so simple as including a logger, or altering a logging framework, can be executed deterministically by codemod instruments like <a rel=\"nofollow\" target=\"_blank\" href=\"https:\/\/docs.openrewrite.org\/\">OpenRewrite<\/a>. So bear that in thoughts earlier than you attain for AI.<\/p>\n<p>The place AI can shine is every time now we have drift that wants coding that&#8217;s extra dynamic than is feasible with regular-expression-based codemod recipes. In a complicated type of the logging instance, this could be turning non-standardised, wealthy log statements right into a structured format, the place an LLM could be higher at turning all kinds of current log messages into the respective construction.<\/p>\n<p>The instance MCP server is included in <a rel=\"nofollow\" target=\"_blank\" href=\"https:\/\/github.com\/birgitta410\/pushing-ai-autonomy-article\">the repository that accompanies<\/a> <a rel=\"nofollow\" target=\"_blank\" href=\"https:\/\/martinfowler.com\/articles\/pushing-ai-autonomy.html\">the unique article<\/a>.<\/p>\n<\/div>\n\n","protected":false},"excerpt":{"rendered":"<p>Service templates are a typical constructing block within the \u201cgolden paths\u201d organisations construct for his or her engineering groups, to make it straightforward to do the correct factor. The templates are imagined to be the function fashions for all of the companies within the organisation, all the time representing the hottest coding patterns and requirements. [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":7084,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[56],"tags":[5565,506,5566],"class_list":["post-7082","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-software","tag-anchoring","tag-application","tag-reference"],"_links":{"self":[{"href":"https:\/\/techtrendfeed.com\/index.php?rest_route=\/wp\/v2\/posts\/7082","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/techtrendfeed.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/techtrendfeed.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/techtrendfeed.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/techtrendfeed.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=7082"}],"version-history":[{"count":1,"href":"https:\/\/techtrendfeed.com\/index.php?rest_route=\/wp\/v2\/posts\/7082\/revisions"}],"predecessor-version":[{"id":7083,"href":"https:\/\/techtrendfeed.com\/index.php?rest_route=\/wp\/v2\/posts\/7082\/revisions\/7083"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/techtrendfeed.com\/index.php?rest_route=\/wp\/v2\/media\/7084"}],"wp:attachment":[{"href":"https:\/\/techtrendfeed.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=7082"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/techtrendfeed.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=7082"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/techtrendfeed.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=7082"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}<!-- This website is optimized by Airlift. Learn more: https://airlift.net. Template:. Learn more: https://airlift.net. Template: 69d9690a190636c2e0989534. Config Timestamp: 2026-04-10 21:18:02 UTC, Cached Timestamp: 2026-06-13 15:24:07 UTC -->