# Create a Prompt-based File Classifier

### Getting Started

Nightfall provides **20+ pre-built file classifiers** out of the box, covering common sensitive document types such as contracts, background checks, financial records, and HR documents.

In some cases, customers need to protect **business-critical document types** **that don’t fit** a standard document type—or require more precision than a general-purpose classifier provides.

{% file src="/files/CLzMrIFijTzCUrO87SLD" %}

A **Prompt-Based File Classifier** lets you define these custom document types using a **natural language description** of the document’s purpose, content, and context. Nightfall then classifies entire files based on **intent, structure, and meaning**.

{% hint style="info" %}
**Important Note**: The detector supports scanning Files, Attachments, and Email Bodies only. We will be adding support for message and field scanning in 2026.&#x20;
{% endhint %}

To create a prompt-based entity detector, navigate to **Detection → Detectors**, then click **+ Custom Detector** in the upper-right corner and select **File Classifier (Prompt-Based)** from the menu.

<figure><img src="/files/0QLq4Ump9RnpDpNkogJD" alt=""><figcaption></figcaption></figure>

This opens the **Prompt-Based Entity Detector** design tab, shown below.

<figure><img src="/files/HDa7IpV6JMDgiJo4quNE" alt=""><figcaption></figcaption></figure>

### How Nightfall Interprets File Classifier Prompts

Prompt-based file classifiers use an LLM to evaluate the **entire document** and determine whether it matches the document type you describe.

Accuracy improves when you clearly describe **what the document is**, **what it typically contains**, **the context in which it’s used**, and **what should not be classified as a match**.

### Understanding Prompts, Keywords, and Sample Files

Prompt-based file classifiers use three primary inputs:

* **Prompt** – describes the type of document to detect
* **Keywords** – important terms commonly found in the document
* **Sample File** – a sanitized, representative example of the document. A template or form is OK.&#x20;

Together, these inputs help Nightfall reliably classify documents with high precision.

#### Prompt

The **Prompt** describes the document type you want to classify. It should focus on **intent and structure**, not individual sensitive entities.

A strong prompt typically includes:

* **Document type** (what the file represents)
* **Purpose** of the document
* **Key sections or information types**
* **Typical use cases or workflows**
* **What should not be considered this document type**

**Prompt example**

Custom Mortgage Application

> Detect a completed mortgage application form.
>
> This document collects borrower personal information, employment details, income, assets and liabilities, property information, and loan request details.
>
> It is used during the mortgage origination process and does not include finalized loan agreements or closing disclosures.

#### Keywords

**Keywords** help reinforce classification by highlighting terms commonly found in the document.

Keywords should:

* Be comma-separated
* Reflect section headers, labels, or repeated concepts
* Be descriptive but not overly specific

**Example keywords**

Custom Mortgage Application

```
Mortgage Application, Borrower, Assets & Liabilities, Employment, Income, Property

```

#### Sample File

The **Sample File** provides Nightfall with a concrete example of the document type you want to classify.

Best practices for sample files:

* Use a **realistic but sanitized** document
* Include representative sections and structure
* Avoid production secrets or live customer data
* Upload a single, complete document (PDF, XLSX, etc.)

The sample file is used only to guide classification and improve precision.

### Test Prompt

Once you are satisfied with the classifier definition, click **Test Prompt** to run a **prompt hygiene check**.

During this check, Nightfall evaluates the **Prompt**, **Keywords**, and **Sample File** together to confirm that the classifier can accurately identify the document type and meet Nightfall’s detection quality standards.

If the prompt **passes the hygiene check**, the file classifier can be:

* Added to your **Custom Detectors** list
* Used in a **Detection Rule**
* Included in a **Policy** for monitoring, alerting, or enforcement

If the prompt **does not pass**, Nightfall will guide you to improve it by:

* Clarifying the document intent
* Adjusting keywords
* Providing a more representative sample file

This ensures that file classifiers are precise, reliable, and safe to deploy in production environments.

<figure><img src="/files/6Y1RrFGnBGh6E2s948k2" alt=""><figcaption></figcaption></figure>

#### Sample Prompt and Files&#x20;

{% file src="/files/VCbQIxqSN1O4mDQMZVhH" %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://help.nightfall.ai/detection_platform/custom_detectors/create-a-prompt-based-file-classifier.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
