Use Cases (Updated: 9/18/2026)

Cloud Run inspection job preflight for manufacturing with Claude Code

Check inspection CSVs, photo metadata, approvals, env vars, and secrets before a Cloud Run Jobs handoff.

Cloud Run inspection job preflight for manufacturing with Claude Code

A quality lead is about to hand inspection CSVs and exterior photo metadata to the overnight cloud batch when the line manager stops the release: this lot has not been approved. The CSV mixes pass, hold, and fail rows. A photo URI appears to include a worker-like name. The environment-variable sheet still contains a value that looks like an API key. The job might run, but the team will struggle later when a supplier report, an audit, or a defect investigation asks why those records moved.

This article builds a preflight workflow with Claude Code before manufacturing inspection reports are passed to Cloud Run Jobs. Cloud Run Jobs are for run-to-completion batch work: a container starts, performs tasks, and exits instead of listening for HTTP requests. We will not connect to Google Cloud here. The title is scoped as a preflight and contract check, not as a live Cloud Run integration.

The unstable technical points were checked against primary documentation: creating Cloud Run jobs, environment variables for jobs, secrets for jobs, service identity for jobs, and Claude Code settings. The important boundary is simple: the local validator proves only the local input contract, not authentication, IAM, storage access, or production behavior.

Key Takeaways

  • Put the inspection CSV, photo URI rules, Cloud Run Job settings, and approval checklist into one release-before-handoff review.
  • Ask Claude Code to read columns, value types, approval state, naming rules, environment variables, and Secret Manager boundaries.
  • Keep human judgment for lot holds, supplier explanations, retention policy, service account scope, and final quality approval.
  • Use fictional local fixtures first. This article does not call Cloud Run, Cloud Storage, Secret Manager, or a factory MES.
  • The single primary CTA is training and consultation for designing this boundary in a company workflow.

Workflow: Turn Inspection Reports Into A Cloud Job Contract

The target workflow is common in factories that run visual inspection, dimensional inspection, equipment checks, or end-of-shift quality summaries. Inputs usually include inspection_results.csv, a list of photo URIs, an environment-variable sheet for the batch job, and a quality approval checklist. MES means manufacturing execution system: the internal system that tracks work orders, process state, and inspection results.

Do not begin by asking AI whether the lot is good. Begin by defining the contract that an input must satisfy before the job receives it. In this example, the CSV must contain report_id, line_id, product_code, lot_no, measured_value, unit, status, inspector, approved, photo_uri, and retention_until. The allowed values for status are pass, hold, and fail. Rows whose approved value is not yes do not move into the job input.

Photo URIs should be readable without turning into a hidden note field. A better pattern is gs://factory-qc-evidence/line-a/2026-09/LOT-1042/report-QC-9001-01.webp, using the line, month, lot, and report ID. Do not put worker names, email addresses, phone numbers, or full names in object keys. Related existing workflows cover manufacturing quality incident reports and manufacturing GKE manifest release reviews. This article sits between those two: the cloud batch handoff contract.

Then review the Cloud Run Job settings. Google Cloud documents that job environment variables are injected as key/value pairs visible to code running in the container, and it warns not to use environment variables for secrets. For secrets, use Secret Manager references. For access to Google Cloud APIs, review the job service identity, which is the service account used by the job. Claude Code can turn those facts into a checklist, but a human still approves the account and roles.

flowchart TD
  A[Prepare inspection CSV locally] --> B[Check photo URI and retention rules]
  B --> C[Review Cloud Run Job env and secret boundaries]
  C --> D[Use Claude Code to draft the issue table]
  D --> E[Quality owner reviews hold and fail rows]
  E --> F[After approval, a human passes it to gcloud or CI]

What Claude Code Handles And What People Decide

Claude Code should handle repeatable contract checks. It can detect missing columns, nonnumeric measurements, unapproved rows, suspicious photo URI patterns, image values still using :latest, a serviceAccount left as default, and environment variables whose names look like PASSWORD, TOKEN, or API_KEY. It is also useful for comparing the CSV, JSON job settings, and checklist side by side, then writing a review table.

People decide quality responsibility and operational risk. A human decides whether a hold lot needs retesting, whether to stop shipment, how to explain a defect to a supplier, whether a photo retention date satisfies the contract, which service account permissions are the minimum needed, and when an overnight job must be stopped. Claude Code output is evidence for discussion. It is not a legal opinion, not a quality warranty, and not proof that Google Cloud IAM is correct.

For Claude Code permissions, use settings to restrict file and command access. Keep .env files and production CSVs out of the prompt. Work with fixed fixtures first, then move the review table into the operational procedure. The request to Claude Code is not “upload this”; it is “check whether this is safe and complete enough for a human-approved upload.”

Three Use Cases

Use case 1: Decide whether inspection CSV rows may enter the job

Input: inspection CSV, column definition, allowed status values, approval field, and retention date. The same file often contains pass, hold, and fail rows.

Output: a table of missing columns, invalid dates, unapproved rows, nonnumeric measurements, and missing retention dates. The output separates rows that may move, rows requiring human review, and rows that must stay out.

Human check: the quality owner decides whether a hold or fail row is excluded, retested, or escalated to a full lot stop.

Use case 2: Keep personal or temporary data out of photo URIs

Input: photo URI list, naming rule, line ID, lot number, and report ID. Under time pressure, a photo may be saved with a worker name, device name, or temporary folder in the object key.

Output: findings for email-like strings, phone-like strings, human-readable names, private, and tmp. Claude Code can also propose a safer URI shape.

Human check: the team decides the smallest traceable ID, what information must stay in the restricted ledger, and which object-key patterns are allowed.

Use case 3: Review the Cloud Run Job secret boundary

Input: Cloud Run Job settings JSON, environment-variable table, keys planned for Secret Manager, service account name, retry count, and timeout.

Output: a table showing whether API_KEY, PASSWORD, TOKEN, or SECRET values appear as plain env vars, whether secret references exist, whether the service account is dedicated, and whether the image avoids :latest.

Human check: cloud administrators decide the Secret Manager resources, least-privilege roles, and whether a failed job can be retried safely.

Copy-Paste Prompt

You are the preflight reviewer for a manufacturing inspection report before handoff to a Cloud Run Job.
The goal is to align the inspection CSV, photo URI rules, Cloud Run Job settings, and approval checklist before execution.

Inputs:
- Inspection CSV sample:
- Photo URI naming rule:
- Cloud Run Job settings JSON:
- Approval checklist:
- Retention and deletion rules:

Check:
1. Missing required columns
2. measured_value that is not numeric
3. status values outside pass/hold/fail
4. approved values that are not yes
5. photo_uri values containing personal names, emails, phone numbers, tmp, or private
6. Cloud Run Job image still using latest
7. env values containing plain API_KEY/PASSWORD/TOKEN-like secrets
8. serviceAccount not using a default account and listing permissions to confirm

Output:
- A table with "ready", "human review", and "blocked"
- Fix suggestions
- Items a human must approve
- Untested boundaries

Constraints:
- Do not connect to real cloud services
- Do not preserve production CSV data or personal data in the output
- Do not insert ClaudeCodeLab, training links, or site-owned CTAs into the generated artifact

Executable Local Validator

The following code checks only fixed article fixtures. It does not call the Cloud Run API, Cloud Storage, Secret Manager, a factory MES, or the network. If you save it locally, use a path such as tools/inspection-job-preflight.mjs; this does not imply the file already exists in this repository.

const requiredColumns = [
  "report_id",
  "line_id",
  "product_code",
  "lot_no",
  "measured_value",
  "unit",
  "status",
  "inspector",
  "approved",
  "photo_uri",
  "retention_until"
];

const inspectionCsv = `report_id,line_id,product_code,lot_no,measured_value,unit,status,inspector,approved,photo_uri,retention_until
QC-9001,line-a,P-441,LOT-1042,0.31,mm,pass,EMP-014,yes,gs://factory-qc-evidence/line-a/2026-09/LOT-1042/report-QC-9001-01.webp,2027-09-30
QC-9002,line-a,P-441,LOT-1042,not-number,mm,hold,EMP-014,no,gs://factory-qc-evidence/private/[email protected],2027-09-30
QC-9003,line-b,P-882,LOT-2099,12.8,N,review,EMP-091,yes,gs://factory-qc-evidence/line-b/tmp/LOT-2099/report-QC-9003.webp,`;

const jobConfig = {
  name: "inspection-summary-job",
  image: "asia-northeast1-docker.pkg.dev/factory/prod/inspection-summary:latest",
  serviceAccount: "default",
  maxRetries: 3,
  timeoutSeconds: 1800,
  env: {
    REPORT_BUCKET: "factory-qc-evidence",
    API_KEY: "plain-text-key"
  },
  secrets: {
    DB_PASSWORD: "projects/123456789/secrets/qc-db-password:2"
  }
};

function parseCsv(text) {
  const [headerLine, ...rows] = text.trim().split("\n");
  const headers = headerLine.split(",");
  return rows.map((line) => {
    const values = line.split(",");
    return Object.fromEntries(headers.map((header, index) => [header, values[index] ?? ""]));
  });
}

function looksLikeIsoDate(value) {
  return /^\d{4}-\d{2}-\d{2}$/.test(value) && !Number.isNaN(Date.parse(value));
}

function validateRows(rows) {
  const issues = [];
  const allowedStatus = new Set(["pass", "hold", "fail"]);

  for (const [index, row] of rows.entries()) {
    const rowNo = index + 1;
    for (const column of requiredColumns) {
      if (!(column in row) || row[column].trim() === "") {
        issues.push({ scope: `row ${rowNo}`, severity: "block", message: `missing ${column}` });
      }
    }
    if (!Number.isFinite(Number(row.measured_value))) issues.push({ scope: `row ${rowNo}`, severity: "block", message: "measured_value must be numeric" });
    if (!allowedStatus.has(row.status)) issues.push({ scope: `row ${rowNo}`, severity: "block", message: "status must be pass, hold, or fail" });
    if (row.status !== "pass" || row.approved !== "yes") issues.push({ scope: `row ${rowNo}`, severity: "review", message: "human approval required before handoff" });
    if (!looksLikeIsoDate(row.retention_until)) issues.push({ scope: `row ${rowNo}`, severity: "review", message: "retention_until must be an ISO date" });
    if (/@|\b\d{2,4}[- ]\d{2,4}[- ]\d{3,4}\b|private|tmp/i.test(row.photo_uri)) issues.push({ scope: `row ${rowNo}`, severity: "review", message: "photo_uri may expose personal or temporary data" });
  }
  return issues;
}

function validateJobConfig(config) {
  const issues = [];
  if (/:latest\b/.test(config.image)) issues.push({ scope: "job.image", severity: "block", message: "pin the image tag or digest instead of latest" });
  if (!config.serviceAccount || config.serviceAccount === "default") issues.push({ scope: "job.serviceAccount", severity: "block", message: "use a dedicated service account" });
  for (const key of Object.keys(config.env ?? {})) {
    if (/(API_KEY|PASSWORD|TOKEN|SECRET)/i.test(key)) issues.push({ scope: `job.env.${key}`, severity: "block", message: "move secrets to Secret Manager references" });
  }
  if (!config.secrets || Object.keys(config.secrets).length === 0) issues.push({ scope: "job.secrets", severity: "review", message: "list required Secret Manager references" });
  if (!Number.isInteger(config.maxRetries) || config.maxRetries < 0 || config.maxRetries > 5) issues.push({ scope: "job.maxRetries", severity: "review", message: "confirm retry count with operations" });
  return issues;
}

const rows = parseCsv(inspectionCsv);
const report = [...validateRows(rows), ...validateJobConfig(jobConfig)];
console.table(report);
process.exitCode = report.some((item) => item.severity === "block") ? 1 : 0;

This proves only local parsing and local fixture validation. It does not prove that a Cloud Run Job can be created, that a service account has the right roles, that a Secret Manager secret exists, that a photo object exists, or that the batch completes in production.

Pitfall: Causes And Concrete Fixes

The first failure is letting hold rows move because “someone will review them later.” The cause is mixing aggregation with quality judgment. Fix it by splitting pass, hold, and fail before the job input is created. Send hold and fail rows to a review queue, not to the Cloud Run Job payload.

The second failure is treating photo URIs as a convenient note field. Once worker names, emails, device names, tmp, or private appear in object keys, later deletion and access explanations become harder. Fix it by using only line, month, lot, and report ID in the URI, and by keeping worker identity or judgment reasons in a separate restricted ledger.

The third failure is treating environment variables and secrets as the same thing. Cloud Run Jobs can use environment variables, but Google Cloud warns against storing secrets there and points to Secret Manager. Fix it by keeping nonsecret settings in env and moving connection strings, API keys, passwords, and tokens to secret references.

The fourth failure is leaving the service account as default. The cause is assuming that “the job runs” means “permissions are designed.” Fix it by creating a dedicated job service account, granting only the roles required by each Google Cloud API, and adding the approver to the checklist.

Small ROI Measurement

Measure blocked work rather than inventing a savings percentage. For two weeks, record CSV rows, blocked issues, human-review issues, resubmissions, time from CSV export to job handoff, and overnight calls. After adding the preflight, record the same fields for another two weeks. Useful signals are pre-detected unapproved rows, photo URI fixes, secret-migration findings, and handoff rejections before the night shift.

The goal is not to claim that Claude Code always saves a fixed number of minutes. The factory, line count, approval structure, and job frequency matter. The first ROI target is catching inputs that should not enter the batch while the right humans are still available.

FAQ

Q. Could this be a Cloud Run service instead of a Job?

A. Use a service for long-lived HTTP handling. Use a Job when the container processes a batch and exits. This article only covers a local preflight before a Cloud Run Jobs handoff.

Q. Can I show the real CSV to Claude Code?

A. Start with anonymized fixtures. For production CSVs, confirm internal rules for permissions, storage location, audit logs, and prohibited columns. This article is not legal or audit advice.

Q. Is adding this validator to CI enough?

A. No. CI can block part of the input contract. Quality approval, service identity, Secret Manager references, IAM, and actual job execution logs still need separate review.

Q. What should I give Claude Code?

A. Give fixed fixtures, column definitions, naming rules, job JSON, and an approval checklist. Do not paste .env files, production keys, unmasked personal data, or supplier contracts.

Put It Into Company Operations

A manufacturing cloud handoff preflight is not just code. Quality, operations, information systems, and cloud administrators need a shared line between checks delegated to AI and decisions held by humans. For help designing the permission boundary, review table, prompt, and ROI sheet around Cloud Run Jobs and inspection CSVs, use training and consultation.

What I Actually Tested

I tested the JavaScript validator above with node against local fixed fixtures. The output detects a nonnumeric measured_value, unapproved rows, an invalid status, photo_uri values containing private and tmp, an image using :latest, the default service account, and a plain API_KEY.

The official URLs checked were the Cloud Run Jobs creation page, Jobs environment variables, Jobs secrets, Jobs service identity, and Claude Code settings. I did not run gcloud run jobs create, call the Cloud Run API, read Cloud Storage, access Secret Manager, verify IAM, connect to an MES, or inspect a production CSV. The evidence here is only that the local input contract check works.

#claude-code #manufacturing #Cloud Run #inspection CSV #approval flow
Free

Free PDF: Claude Code Cheatsheet

Enter your email and download the one-page Claude Code cheatsheet for commands, review habits, and safe workflows.

We handle your data with care and never send spam.

Level up your Claude Code workflow

Start with the free PDF, use Gumroad guides when you need repeatable workflows, and book consultation when rollout or revenue paths need human judgment.

Masa

About the Author

Masa

Engineer focused on practical Claude Code workflows. Runs claudecode-lab.com, a 10-language technical media site.