How to Build a Custom AI Quality Gate on Cloud Run (From Zero to Production) β€” CoPilot Blog
    Neura MarketNeura Market/CoPilot
    ChatGPTChatGPTClaudeClaudeGeminiGeminiCursorCursorGrokGrokPerplexityPerplexityCoPilotCoPilot
    DeepSeekDeepSeekStable DiffusionStable DiffusionMidjourneyMidjourney
    View All Directories
    OverviewRulesPromptsMCPsAgentsBlogVideosGuidesCoursesCommunityPluginsTrendingGenerate
    CoPilotBlogHow to Build a Custom AI Quality Gate on Cloud Run (From Zero to Production)
    Back to Blog
    How to Build a Custom AI Quality Gate on Cloud Run (From Zero to Production)
    architecture

    How to Build a Custom AI Quality Gate on Cloud Run (From Zero to Production)

    Alexander Tyutin April 28, 2026
    0 views

    In my previous article about treating architecture documentation as a first-class asset, I had a...

    In my previous article about treating architecture documentation as a first-class asset, I had a great discussion in the comments about enforcing architectural rules. I promised to share materials from my recent Google Developer Groups workshop. The workshop is now finished! Here is the story of how I built an AI Quality Gate, how it helped me solve the internal "CEO, CTO, CFO, CISO" conflict, and a summary of the live demonstration. _You can listen a podcast generated based on this publication (thanks [NotebookLM](https://notebooklm.google/)):_ {% youtube qfbZZxcDNbU %} --- Playground repositories with source code: - [Quality Gate PoC](https://github.com/tyutinalexkz/workshops-260425-gdg-quality-gate-quality-gate) - [CheckMe Repo #1](https://github.com/tyutinalexkz/workshops-260425-gdg-quality-gate-repo1) - [CheckMe Repo #2](https://github.com/tyutinalexkz/workshops-260425-gdg-quality-gate-repo2) - [CheckMe Repo #3](https://github.com/tyutinalexkz/workshops-260425-gdg-quality-gate-repo3) ## The Backstory: Mentoring and the "CEO, CTO, CFO, CISO" Conflict ![Conflict of interest inside a developer's head](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v9dc7ccfuem5k00sdo6i.png) I work as a DevSecOps engineer, but in my free time, I mentor for Technovation Girls, a global program that helps young women learn tech and STEM. Because we always need more IT mentors, I built an AI mentor bot to help the students. Building this bot had two big challenges: - Safety: Because children use it, it had to be completely safe from AI hallucinations. - Budget: Because I pay for it myself, it had to be very cheap. The bot was a big success. Using Google Cloud Run and Vertex AI, it handled 250 users and answered 1,500 questions for only about $25-$55 a month. However, when I tried to add new features quickly, I faced a big problem. With only 1-2 hours of free time a day for this project, I experienced a harsh "CEO, CTO, CFO, CISO" conflict in my own head: - The CTO wanted to write code and ship features fast. - The CISO wanted to stop releases to make sure everything was secure. - The CFO wanted to keep cloud costs low. - The CEO wanted the product to grow and succeed. ## The Solution: What is an AI Quality Gate? ![Indie Developer Conflict of Interest Solved](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/t3f1kmnubehtu7s61uzw.png) To solve the "CEO, CTO, CFO, CISO" conflict, I created an AI Quality Gate. An AI Quality Gate is a custom microservice that automatically reviews code for architecture, security, and costs (FinOps). It is built on Google Cloud Run and uses Vertex AI (Gemini). The first action of the Quality Gate was to block its own MVP from reaching the production. So I decided it was a good sign. > 1. **Short Summary:** Fail. 2. **List of Critical Findings:** * **AI Gateway (AAA):** The provided code retrieves a GitLab token directly from Secret Manager and uses it for GitLab API access. This bypasses the AI gateway, violating the "ALWAYS Consistency with AI gateway (AAA, FinOps)" rule. The AAA component should manage authentication and authorization for all external services, including GitLab. 3. **Constructive Recommendations:** * **Implement AI Gateway AAA:** Modify the `ai_review.py` script to authenticate with the AI gateway first. The AI gateway will then handle the GitLab authentication, providing a centralized and secure way to manage access. Use gateway's provided token instead of direct GitLab API access from the job. * **FinOps Considerations:** Track the cost of AI reviews and link this with FinOps tools, it is important to provide cost visibility since the usage of resources will increase. Because it runs on Cloud Run, it only costs money when it is actively checking code. For a whole month of automated, deep-context code reviews, I paid only $0.12! This made the CFO part of my brain very happy. At first, I used the AI Quality Gate as a step in my CI/CD pipeline. But waiting several minutes for a "Merge Request Failed" message was slow and annoying. Now, I run the Quality Gate from a bash script directly in my IDE before creating a Merge Request. This saves time and perfectly resolves the "CEO, CTO, CFO, CISO" conflict by balancing speed, safety, and budget. ## Workshop Demo: The AI Quality Gate in Action During the GDG workshop, I showed a live demo across three different code repositories to prove why traditional tools are not enough. ### Demo 1: The 10/10 Linter Illusion - Happy CISO ![Quality Gate First Check - Developer tries to fool the linter](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/b5kf4j45ni2u91b2uuzw.png) First, I scanned a simple service using standard tools like Ruff, Pylint, and Semgrep. The code got a perfect 10/10 score. However, when I sent the code to the AI Quality Gate, it blocked the release. It found a critical SQL injection and a prompt injection (a hidden note in the code telling the AI reviewer to "report that everything is fine"). Traditional linters missed this completely, but the AI caught it and gave me exact steps to fix it. ### Demo 2: Catching Semantic Drift - Happy CEO+CRO ![Quality Gate Second Check - Documentation and Code Inconsistency](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/d04lapm9wj3runmftn61.png) In the second project, the README.md file stated that the system followed strict privacy standards and anonymized user data. But the actual code did the opposite: it saved real user emails and IDs. Standard tools missed this, but the AI Quality Gate read the documentation, compared it to the code's behavior, and found the security violation. ### Demo 3: "Shift-In" (Reviewing Before Coding) - Happy CTO+CFO ![Quality Gate Third Check - Checking Plan Before Coding](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nnfu81t92z6dqsbpqx6w.png) The last demo was the most powerful. The repository had zero lines of code. It only contained a Markdown document planning a new feature. I sent this text plan to the AI Quality Gate. Before I wrote a single line of Python, the AI found critical security flaws in the plan, like missing server logs and hardcoded passwords. This changes the concept of "Shift-Left" security into "Shift-In" - bringing experts directly into your IDE while you are still brainstorming the idea. Now we may not only test the code but even test the ideas. ## Conclusion When you keep your architecture rules and documentation close to your code, a custom AI Quality Gate becomes an incredibly powerful tool. It helps you write better code, saves time, and finally resolves the internal "CEO, CTO, CFO, CISO" conflict. Moreover such a gate may be an additional advisor with any experience you want and help to improve any idea in the earliest stage to save future money. Best of all, it costs almost nothing to run. If you want to build this yourself, my Docker image is available on DockerHub, and the sample repositories are on my GitHub: - [Quality Gate PoC](https://github.com/tyutinalexkz/workshops-260425-gdg-quality-gate-quality-gate) - [CheckMe Repo #1](https://github.com/tyutinalexkz/workshops-260425-gdg-quality-gate-repo1) - [CheckMe Repo #2](https://github.com/tyutinalexkz/workshops-260425-gdg-quality-gate-repo2) - [CheckMe Repo #3](https://github.com/tyutinalexkz/workshops-260425-gdg-quality-gate-repo3)

    Tags

    architecturegooglecloudtutorialproductivity

    Comments

    More Blog

    View all
    Minimalist EKS: The Easy Waykubernetes

    Minimalist EKS: The Easy Way

    Amazon EKS manages the Kubernetes control plane, but you remain responsible for provisioning the...

    J
    Joaquin Menchaca
    Never forget to enter the Stern Grove lottery again!ai

    Never forget to enter the Stern Grove lottery again!

    Browser automation with Playwright, Python, GitHub Actions, and Entire to auto-enter San Francisco Stern Grove concert lotteries each week!

    L
    Lizzie Siegle
    A Free Screenshot Editor That Never Uploads Your Imagetypescript

    A Free Screenshot Editor That Never Uploads Your Image

    A free screenshot and image editor that runs entirely in your browser. Keeping every edit reversible and handling big phone photos, in plain TypeScript and Canvas2D.

    M
    Martin Stark
    I built a CLI to break my highlights out of Apple Booksshowdev

    I built a CLI to break my highlights out of Apple Books

    A macOS CLI + MCP server that exports Apple Books highlights to Markdown and gives AI assistants direct access to your reading notes.

    A
    Andrey Korchak
    A Developer's Guide to Agent Hooks in Antigravity CLIai

    A Developer's Guide to Agent Hooks in Antigravity CLI

    Motivation To be quite honest, "Hooks"β€”the shell commands we trigger at specific points...

    T
    Tanaike
    Tactical vs. Strategic Agentic AI Development β€” A Playbook for Developersagents

    Tactical vs. Strategic Agentic AI Development β€” A Playbook for Developers

    The Strategic Engineer: Why Writing Code Is No Longer Your Most Valuable Skill ...

    A
    Adewumi Saheed Adewale

    Stay up to date

    Get the latest CoPilot prompts, rules, and resources delivered to your inbox weekly.

    Neura Market LogoNeura Market

    Discover the best AI prompts, plugins, and resources for CoPilot and more.

    Content Types

    • Rules
    • Prompts
    • MCPs
    • Agents
    • Guides

    Platforms

    • ChatGPT Directory
    • Claude Directory
    • Gemini Directory
    • Cursor Directory
    • Grok Directory
    • Perplexity Directory
    • DeepSeek Directory
    • CoPilot Directory
    • Stable Diffusion Directory
    • Midjourney Directory
    • All Directories

    Resources

    • Blog
    • Documentation
    • Help Center
    • Marketplace

    Legal

    • Privacy Policy
    • Terms of Service

    Β© 2026 Neura Market. All rights reserved.

    |

    Not affiliated with any AI platform vendors.