What are the actual best Claude Code skills or system prompts for getting it to write reliable GitLab CI/CD yaml files without it constantly hallucinating deprecated runner tags or making up its own syntax for the variables? Ive been a DevOps lead for about six years now and I usually just hand-roll my pipelines but we got a huge influx of new microservices this month—about 40 of them for a fintech client in London—and I thought Id save time by using the new Claude Code CLI stuff.
Its driving me crazy. One minute its writing perfect bash scripts for my deployment stages and the next its trying to use some weird environment syntax that havent existed since 2019. I've tried feeding it my own internal docs as context but it seems to get distracted by the default training data or something.
I have to get these pipelines live by Friday and Im already fifty bucks deep into the API credits just trying to get it to stop messin up the cache keys and the rules:if logic. Is there a specific way to prompt it or a specific skill I can define to keep it grounded in modern YAML standards? Just feeling like Im fighting the tool more than Im actually coding at this point...
Re: "Honestly, I've been down this exact road and..."
Building on the earlier suggestion, I'd say you gotta be super careful with how much freedom you give the CLI. If you're burning through credits like that, it's usually because the context window is getting messy with all those failed attempts. I would suggest creating a dedicated reference file and explicitly telling Claude to only use the syntax found there. Tell it 'If it's not in this file, it doesn't exist.' Also, watch out for those Anthropic Claude 3.5 Sonnet API costs when you're scaling to 40 services. I'd make sure to feed it a 'golden' example of a working job and force it to use that as a strict template. It's way cheaper to have it copy-paste and swap variables than letting it 'innovate' on your logic. Just double check those rules:if statements tho... it still loves to sneak in old only/except syntax when it gets lazy lol.
Honestly, I've been down this exact road and it's a nightmare when you're on a deadline for a client like that. In my experience, these models love to hallucinate old GitLab syntax because the internet is just full of outdated StackOverflow posts from 2018. Over the years, I've learned that Claude needs a very specific leash. I tried using it for a similar mass-migration of microservices last year and kept getting the same rubbish with the rules:if logic. It felt like I was spending more time debugging the AI than actually building the infra... I've found a few things that help keep it from going off the rails: