> ## Documentation Index
> Fetch the complete documentation index at: https://docs.wayak.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Quality defect analysis

> Identify defect patterns across production lines, shifts, and operators to reduce scrap rates

Quality issues rarely come from a single source. They emerge from the intersection of materials, machines, operators, and processes. Catching a pattern — like a defect spike every time a specific material lot runs on Line 3 during the night shift — requires cross-referencing data that typically lives in separate systems. By the time someone manually assembles that picture, you have already scrapped hundreds of units.

This use case connects your quality management system and production database to a Wayak agent that analyzes defect patterns on demand. You can ask natural-language questions like "Which line had the highest scrap rate last week?" or "Show me defect trends for product X by shift." The agent pulls from your SOPs knowledge space to recommend corrective actions grounded in your own procedures.

***

## What you need

<CardGroup cols={2}>
  <Card title="Data sources" icon="database">
    * **Quality management system** — Defect logs with defect type, severity, line, shift, operator, and timestamp
    * **Production database** — Output records to calculate defect rates as a percentage of total production
  </Card>

  <Card title="Knowledge spaces" icon="book-open">
    * **Standard operating procedures (SOPs)** — Upload process-specific SOPs so the agent can reference correct procedures when recommending corrective actions
    * **Quality manual** — Your quality standards, acceptable defect thresholds, and escalation criteria
  </Card>
</CardGroup>

**Semantic layer:** Define these in your ontology before setting up the agent.

| Component | Name              | Definition                                                                                               |
| --------- | ----------------- | -------------------------------------------------------------------------------------------------------- |
| Object    | Defect Record     | Maps to the quality system defect log. Represents a single defect event with type, severity, and context |
| Object    | Inspection Result | Maps to inspection records. Represents a pass/fail outcome for a batch or unit                           |
| Metric    | Defect Rate       | Total defects divided by total units produced, as a percentage, over a given period                      |
| Metric    | Scrap Cost        | Sum of material and labor cost for scrapped units, pulled from ERP cost postings                         |
| Dimension | Defect Category   | Groups defects by root cause type: material, process, operator, machine                                  |
| Dimension | Severity          | Classifies defects as critical, major, or minor based on quality standards                               |

<Tip>
  See [building a semantic layer](/quickstart/build-semantic-layer) for a step-by-step guide.
</Tip>

***

## Agent setup

<Steps>
  <Step title="Create the agent">
    Go to **Agent Space** > **New agent**.

    | Field    | Value                                           |
    | -------- | ----------------------------------------------- |
    | **Name** | Quality Assurance Analyst                       |
    | **Role** | Quality control specialist                      |
    | **Goal** | Identify defect patterns and reduce scrap rates |
  </Step>

  <Step title="Set the description">
    > You are a quality control analyst focused on reducing defect rates. When asked about quality, always start with the current defect rate trend before diving into specifics. Group defects by category (material, process, operator, machine) and highlight the highest-impact area first. Use precise numbers and percentages. Recommend corrective actions based on data and reference the relevant SOP when available. Do not make assumptions about causes you cannot verify from the data.
  </Step>

  <Step title="Scope data access">
    Grant access to:

    * Quality management system data source (defect logs and inspection results)
    * Production database data source (output records)
    * SOPs knowledge space
    * Quality manual knowledge space
    * Defect Record and Inspection Result objects in the semantic layer
  </Step>

  <Step title="Add skills">
    <AccordionGroup>
      <Accordion title="Analyze defect patterns">
        **Trigger:** User asks about defect trends, quality issues, or scrap rates

        1. Identify the time range, product, or line from the user's request, defaulting to the last 30 days if unspecified.
        2. Pull all defect records matching the criteria from the quality management system.
        3. Calculate the overall defect rate and compare it to the previous period.
        4. Group defects by category (material, process, operator, machine) and rank by count.
        5. Cross-reference the top defect category with shift and line data to identify correlations.
        6. Reference the relevant SOP from the knowledge space and note any deviations that could explain the pattern.
        7. Present findings with a summary table and a recommended corrective action.
      </Accordion>

      <Accordion title="Generate Pareto analysis">
        **Trigger:** User asks for a Pareto chart or top defect causes

        1. Pull all defect records for the specified period.
        2. Count defects by type and sort in descending order.
        3. Calculate the cumulative percentage for each defect type.
        4. Identify the defect types that account for 80% of total occurrences.
        5. Present the Pareto table with defect type, count, percentage, and cumulative percentage.
      </Accordion>
    </AccordionGroup>
  </Step>
</Steps>

***

## Automation

### Playbook: Weekly quality summary

<Steps>
  <Step title="Set the trigger">
    Schedule the playbook to run every Monday at 7:00 AM.
  </Step>

  <Step title="Build the workflow">
    The playbook compiles the previous week's quality data into a summary report with trend comparisons.

    1. **Query step** — Pull all defect records and production output for the previous 7 days.
    2. **Query step** — Pull the same data for the week before that (for trend comparison).
    3. **Format step** — Build a summary showing defect rate by line, top defect categories, and week-over-week change.
    4. **Condition step** — If any line's defect rate increased by more than 1 percentage point, add it to a "needs attention" section.
  </Step>

  <Step title="Configure delivery">
    Send the report via email to the quality manager and plant manager. Include the overall defect rate and trend direction in the subject line.
  </Step>

  <Step title="Test and activate">
    Click **Run now** to test with live data, then toggle to **Active**.
  </Step>
</Steps>

***

## What's next

<CardGroup cols={2}>
  <Card title="Maintenance scheduling" icon="arrow-right" href="/use-cases/manufacturing/maintenance-scheduling">
    Automate equipment service tracking and get alerts before failures happen.
  </Card>

  <Card title="All manufacturing use cases" icon="list" href="/use-cases/manufacturing">
    See the full list.
  </Card>
</CardGroup>
