Get them back: 10 AI skills for the list you already own
segment-builder
stop sending everyone everything
How the two work together
Claude thinks it through. Paste the Claude prompt into Claude Code, or drop the folder into your skills folder. Claude does the judgement: what to look for, what is worth doing, what is right.
Codex gets it done. At the hand-off point Claude runs Codex on your machine with one command and passes it the Codex prompt. Codex does the mechanical part and hands the result back. Claude checks it before you see it.
No API key to set up: Claude calls the Codex you already have installed. If Codex is not installed, Claude does that half itself and tells you.
Prompt for Claude
--- name: segment-builder description: Splits your customer list into a small number of segments built from what people actually did, with the lawful basis, the transparency wording and the size of each one written down beside it. Use when you are sending the same email to everybody and it is working less every time. --- # Stop sending everyone everything, and be able to say why each group got what it got You give this whatever records what your customers did: a till export, a booking-system CSV, an online ordering report, a loyalty spreadsheet, or the three of them that do not agree with each other. You get back a small set of segments defined by behaviour you can point at, the count in each one, the lawful basis each segment can be emailed under, the sentence you have to put on your sign-up form before you use it, and a named list of the segments the skill refused to build and the reason it refused. ## What it does 1. **Reconcile the sources before you segment anything, and keep the join key visible.** A pub with a booking system, a card terminal and a loyalty app has three customer lists and one customer. Pick the join key deliberately: lowercase email is usually the only stable one, because names are typed differently every visit and mobile numbers are shared across a household. Record how many rows each source contributed, how many matched, and how many did not. Rows that could not be matched are not discarded, they are counted and reported, because a segment built from the two systems that happened to join is a segment that quietly excludes everyone who only ever paid by card. 2. **Build the behaviour columns first, and only from things that actually happened.** Three columns carry most of the value: how many days since this person last spent money with you, how many separate visits they have made in the period, and what they have spent in total across the period. That is recency, frequency and monetary value, the RFM method, and it has the property that matters here, which is that every value in it is a fact from your own till rather than a guess about a person. Add a fourth if you have it and it is factual: which day of the week they usually come. Do not add estimated lifetime value, propensity scores or anything else the data does not contain. 3. **Refuse to build the segments that quietly become special category data.** This is where a hospitality list goes wrong, and it does not look dangerous at the time. A "vegan menu" segment built from dietary notes on bookings can reveal religious or philosophical belief. A "gluten free" or "nut allergy" segment is data concerning health. The ICO's test is not about how the data was labelled but about what you intend to do with it: you are processing special category data where "your processing intends to make an inference linked to one of the special categories of data" or "you intend to treat someone differently on the basis of inferred information linked to one of the special categories of data", and this applies "regardless of how confident you are that the inference is correct". Its guidance adds that if you profile to infer "ethnicity, beliefs, politics, health status (condition or risks), sexual orientation or sex life", you need an Article 9 condition, and the ICO's direct marketing guidance says that for marketing "You should have 'explicit consent'" because it is unlikely another condition applies. So: an allergy note stays in the kitchen system where it belongs and does not become a marketing segment, unless the customer has separately and explicitly agreed to be emailed on that basis. 4. **Set a minimum segment size and enforce it.** Below roughly fifty people a segment is not a segment, it is a handful of named individuals who will recognise themselves in the email, and the effort of writing separate copy for it is never repaid. Merge anything smaller into its nearest neighbour and say in the output that you did. Four to six segments is the working number for a single-site venue. Somebody who builds fourteen writes fourteen emails once and then writes none. 5. **Write the lawful basis on the segment, not on the campaign.** Each segment gets one of two labels. Specific consent to marketing email. Or the soft opt-in, which under regulation 22(3) of PECR needs the details to have been obtained "in the course of the sale or negotiations for the sale of a product or service to that recipient", the marketing to be of "similar products and services only", and a simple means of refusing to have been given at collection and in every message since. A segment that mixes the two is fine. A segment containing anyone who fits neither is not, and those rows go to a separate list headed "no lawful basis, do not email". The ICO's guidance on the soft opt-in is explicit that it "does not apply to prospective customers or new contacts (eg from bought-in lists)". 6. **Separate the suppression list from the screening list and never confuse the two.** A suppression list holds people who told you to stop. A screening list holds people you have decided not to include this time. The ICO draws the line sharply: "Unlike a suppression list, you don't use a screening list to comply with someone's objection to direct marketing. Use of a screening list is processing for direct marketing purposes." Practically, that means the suppression list is checked against every segment before any send and its exclusions are absolute, while a screening decision is yours to change. Report both counts separately so that a dropping open rate can be traced to the right cause. 7. **Write the transparency sentence the segments require, and put it where people give you their details.** You cannot analyse purchase history to decide what somebody receives and say nothing about it. The ICO's own worked example of adequate wording is one sentence: "We will use your purchase history to tell you about our offers and products that we think you will be most interested in." Its guidance adds the test for whether your wording is honest enough, which is that "If you find it difficult to explain what you want to do, or you don't want to tell people because you think they might object, this is a sign that you should rethink your intended marketing activity." Output the exact sentence for this venue's segments so it can be pasted onto the booking form and the sign-up box. 8. **Attach the message to the segment, one line each, before anyone writes an email.** For each segment: what these people did, what you want them to do next, and the single offer or piece of news most likely to cause it. A group who came four times in ninety days does not need a discount, they need to know about the new menu first. A group who came once eleven months ago needs a reason to remember you exist. If two segments end up with the same line, they are the same segment, and the output should merge them rather than pretending otherwise. 9. **Print the segment table with counts, and keep the refusals underneath it.** Columns: segment name, rule in plain words (for example "spent money in the last 60 days, three or more visits"), count, percentage of the emailable list, lawful basis, message line, and the date the underlying export was taken. Below it, a table headed "not built, and why", listing every segment that was requested or suggested and refused: too small, no lawful basis, or would have inferred special category data. That second table is the one to keep, because it is the record of the decisions that would otherwise be re-made and made differently in six months. ## Then it checks 1. Every segment row shows a count, the percentage of the emailable list it represents, and the date the source export was taken, and the counts of all segments plus the excluded rows add up to the total rows read. 2. No segment is defined by, or derived from, a dietary requirement, an allergy, an accessibility note, a health note, a religious observance or a name-based assumption about origin, and any such request appears in the "not built, and why" table. 3. Every segment carries a lawful basis of `consent` or `soft-opt-in-PECR-22(3)`, and every row that fits neither appears in the separate "no lawful basis, do not email" list with the reason. 4. No segment holds fewer than the stated minimum, and every merge performed to reach that minimum is named in the output. 5. The suppression count and the screening count are reported as two separate numbers, and every segment has been screened against the suppression list before its count is stated. 6. The output contains one transparency sentence, written for this venue, describing the analysis actually being done, and no segment relies on analysis that sentence does not cover. Any check fails: name it, redo that step once. Failed twice: say what is wrong and stop. ## Rules - Public information only. - Never invent a fact, a number or a quote. - Anything sent in someone's name says whose name it is. - Never build a segment from an inference when the fact itself is available. "Ordered the set menu three times" is a fact from your till. "Probably price sensitive" is a story about a person, and the ICO warns that profiling "might perpetuate stereotypes if you make general assumptions based on the information you hold". - Never quote a benchmark, an industry average or an expected open rate at the owner. The only figures in the output are counted from this venue's own export, and every one of them shows the date it was counted. - Never let a segment survive the loss of its lawful basis. If someone unsubscribes they leave every segment at once, not just the one that sent the email, because the right to object under data protection law covers the profiling related to the marketing as well as the marketing itself. - This output is a working document prepared for the owner's solicitor or data protection adviser to check before it is used. It applies published regulator guidance to a customer list; it is not legal advice on your obligations under PECR or the UK GDPR. ## Built from - Information Commissioner's Office, "What is special category data?", https://ico.org.uk/for-organisations/uk-gdpr-guidance-and-resources/lawful-basis/special-category-data/what-is-special-category-data/, latest update shown as 9 April 2024, read 14 September 2026: the inference test and the profiling sentence quoted in step 3, which is the whole basis of the second check. - Information Commissioner's Office, "Collect information and generate leads", https://ico.org.uk/for-organisations/direct-marketing-and-privacy-and-electronic-communications/direct-marketing-guidance/collect-information-and-generate-leads/, no publication date shown on the page, read 14 September 2026: the profiling requirements and the verbatim transparency example in step 7, and the stereotyping warning in the rules. - Information Commissioner's Office, "Respect people's preferences", https://ico.org.uk/for-organisations/direct-marketing-and-privacy-and-electronic-communications/direct-marketing-guidance/respect-peoples-preferences/, no publication date shown on the page, read 14 September 2026: the suppression list versus screening list distinction quoted in step 6. - Information Commissioner's Office, "Plan direct marketing", https://ico.org.uk/for-organisations/direct-marketing-and-privacy-and-electronic-communications/direct-marketing-guidance/plan-direct-marketing/, no publication date shown on the page, read 14 September 2026: the explicit consent position for special category marketing quoted in step 3. - The Privacy and Electronic Communications (EC Directive) Regulations 2003, regulation 22, https://www.legislation.gov.uk/uksi/2003/2426/regulation/22, made 18 September 2003, read 14 September 2026: the verbatim soft opt-in conditions that the lawful-basis label in step 5 is checked against. - rsquaredacademy, "rfm: Customer Segmentation using RFM Analysis", https://github.com/rsquaredacademy/rfm, no publication date shown on the page, read 14 September 2026: the recency, frequency and monetary definitions used in step 2.
Prompt for Codex
# Customer segment builder ## You are given One or more customer or transaction exports from a UK hospitality business: a till report, a booking-system CSV, an online ordering export, a loyalty spreadsheet. Column names vary and the files may not agree. You may also be given a suppression list of email addresses, a consent log showing who opted in to marketing email and when, and a stated minimum segment size (default 50). ## Produce Write these files into `./segments-output/`: 1. `segments.csv` with exactly these columns: `segment_name`, `rule_in_words`, `count`, `pct_of_emailable`, `lawful_basis`, `message_line`, `export_date`. `lawful_basis` is `consent`, `soft-opt-in-PECR-22(3)` or `mixed`. 2. `customers_segmented.csv` with columns: `email_lower`, `segment_name`, `days_since_last_spend`, `visits_in_period`, `total_spend_gbp`, `usual_day`, `lawful_basis`, `source_files`. One row per customer. 3. `no-lawful-basis.csv`, same columns as `customers_segmented.csv` plus `reason`, holding every customer who matched neither consent nor soft opt-in. 4. `not-built.csv` with columns `requested_segment`, `refusal_reason`. Refusal reasons are exactly one of `below minimum size`, `no lawful basis`, `would infer special category data`. 5. `reconciliation.txt`: rows read per source file, rows joined, rows that joined from only one source, suppression matches removed, screening exclusions applied, and the final emailable total. Suppression and screening counts must be two separate numbers. 6. `transparency-sentence.txt`: one sentence describing the analysis actually performed, written for pasting onto a sign-up form. ## Rules - Join on lowercase trimmed email address only. Never join on name or phone number. - Build segments only from: days since last spend, number of visits, total spend, and usual day of week. Never from a dietary note, allergy note, accessibility note, health note, religious observance, nationality, title or a name-based assumption. Any such field encountered is dropped and logged as a `would infer special category data` row in `not-built.csv`. - Produce between four and six segments. Merge any segment below the minimum size into its nearest neighbour and record the merge in `reconciliation.txt`. - Remove every suppression-list match from every segment before counting. - Never write a benchmark, an industry average or an expected open or click rate into any file. Every number must be counted from the supplied data. - Do not send any email, call any marketing API, or contact any person. You produce files only. - Money is in pounds with two decimals. Dates are DD/MM/YYYY. ## Return Print the absolute path of each file written, the segment names with their counts, the emailable total, the suppression count and the screening count as separate figures, and every row of `not-built.csv`. If the totals in `reconciliation.txt` do not add up to the rows read, say so plainly rather than adjusting a number to make them balance.
Built from the best public work on this
Sources for segment-builder
Everything below was opened and read on 14 September 2026. Nothing is cited that could not be loaded.
1. Information Commissioner's Office, "What is special category data?"
https://ico.org.uk/for-organisations/uk-gdpr-guidance-and-resources/lawful-basis/special-category-data/what-is-special-category-data/, latest update shown on the page as 9 April 2024, read 14 September 2026.
The regulator's detailed guidance on Article 9 data, and the single most important source in this pack for anyone segmenting a restaurant list. It lists the special categories as personal data revealing racial or ethnic origin, political opinions, religious or philosophical beliefs or trade union membership, plus genetic data, biometric data used for identification, "data concerning health", data concerning a person's sex life and data concerning sexual orientation. It defines health data through Article 4(15) as "personal data related to the physical or mental health of a natural person, including the provision of health care services, which reveal information about his or her health status", and says explicitly that health data "not only covers specific details of medical conditions, tests or treatment, but includes any related data which reveals anything about the state of someone's health". A nut allergy recorded against a booking is that.
The section that shaped step 3 is the one on inferences, updated on 9 April 2024. It states that whether inferred data triggers Article 9 turns on whether "your processing intends to make an inference linked to one of the special categories of data" or "you intend to treat someone differently on the basis of inferred information linked to one of the special categories of data", and that where either is true "you are processing special category data regardless of how confident you are that the inference is correct". It goes on: "If you carry out any form of profiling which infers things like ethnicity, beliefs, politics, health status (condition or risks), sexual orientation or sex life, you will be processing special category data and must identify an Article 9 condition for processing." The guidance is equally clear in the other direction, and the skill repeats that too: "you do not need a special category condition just to hold these names or images on a customer database". Where the skill departs from the source: the ICO permits the processing with an Article 9 condition, so a halal or vegan segment is not forbidden, it is conditional. The skill refuses to build one anyway unless explicit consent exists on the record, because the condition an owner would have to rely on is explicit consent, and an owner who cannot produce that consent has built a segment they cannot defend.
2. Information Commissioner's Office, "Collect information and generate leads"
https://ico.org.uk/for-organisations/direct-marketing-and-privacy-and-electronic-communications/direct-marketing-guidance/collect-information-and-generate-leads/, no publication date shown on the page, read 14 September 2026.
The chapter of the ICO's direct marketing guidance dealing with profiling, and the source of step 7's wording. It defines profiling as looking at "people's interests, habits and behaviour" and notes it "often also involves predictions or assumptions about people". It then sets four obligations: be fair and tell people what you want to do, ensure you have a lawful basis, understand the risks, and respect people's preferences. On transparency it gives a worked example of adequate wording, which the skill reproduces because it is short enough for a booking form and specific enough to be true: "We will use your purchase history to tell you about our offers and products that we think you will be most interested in." On risk it supplies the sentence behind the fourth bespoke rule, that profiling "might perpetuate stereotypes if you make general assumptions based on the information you hold, or might cause discrimination if you exclude people from products or services based on your profiling". And it supplies the honesty test used in step 7: "If you find it difficult to explain what you want to do, or you don't want to tell people because you think they might object, this is a sign that you should rethink your intended marketing activity."
Where the skill departs from the source: the guidance also covers buying and renting lists from data brokers and sets out due diligence questions for doing so. The skill has no use for that section and does not reproduce it, because this pack exists for the list an owner already holds, and a bought list cannot meet the soft opt-in test in any event.
3. Information Commissioner's Office, "Respect people's preferences"
https://ico.org.uk/for-organisations/direct-marketing-and-privacy-and-electronic-communications/direct-marketing-guidance/respect-peoples-preferences/, no publication date shown on the page, read 14 September 2026.
The chapter that settles two questions owners get wrong in opposite directions. First, that suppression is preferred to deletion: "If someone no longer wants you to use their information for direct marketing purposes, you should put their details onto a suppression or 'do not contact' list, instead of deleting them", and the reason, that "By using a suppression list, you can check any new marketing lists against it." It gives the failure case directly, describing a situation where "If the company had placed the number on a suppression list rather than deleting it, the breach would have been prevented." Second, and this is the distinction step 6 is built on, it separates the two kinds of list: "Don't confuse direct marketing suppression lists with screening lists. You may use a screening list when you have decided to screen out certain people because they don't fit the particular direct marketing campaign that you or a third party are running. Unlike a suppression list, you don't use a screening list to comply with someone's objection to direct marketing. Use of a screening list is processing for direct marketing purposes."
That difference is invisible in most email platforms, which present both as "excluded from this send", and it is the reason the skill insists on two separate counts in its output. Where the skill departs from the source: the ICO says suppression should hold "just enough information about someone to ensure you respect their preferences in the future, so you must not keep more than you need". The skill goes further and specifies the field, a one-way hash or the plain lowercase email and nothing else, because a suppression list that carries a purchase history is a marketing database with a label on it.
4. Information Commissioner's Office, "Plan direct marketing", and PECR regulation 22
https://ico.org.uk/for-organisations/direct-marketing-and-privacy-and-electronic-communications/direct-marketing-guidance/plan-direct-marketing/, no publication date shown on the page, and https://www.legislation.gov.uk/uksi/2003/2426/regulation/22, made 18 September 2003. Both read 14 September 2026.
The ICO page states the position that closes step 3: where special category data is used for direct marketing, "You should have 'explicit consent'. This is because it is unlikely that any other special category condition applies", and adds that explicit consent requires people to "agree in a clear statement", that "You must also specify the type of special category data you want to use", and that the request "should be separate from any other consents". It also names the exact trap this skill guards: "You may be using special category data if you are trying to better target your direct marketing by profiling people. For example, drawing inferences about people's race, political opinions or health from other information."
Regulation 22 supplies the wording behind the lawful-basis label in step 5, requiring for the soft opt-in that the details were obtained "in the course of the sale or negotiations for the sale of a product or service to that recipient", that the marketing is of "similar products and services only", and that a "simple means of refusing" was given at collection and "at the time of each subsequent communication". Where the skill departs: the regulation and the guidance are both silent on segment size, which is a commercial judgement rather than a legal one. The minimum of around fifty in step 4 is stated as the skill's own rule of thumb and is labelled as such, not attributed to either source.
Best public prompt we found for this job
The closest public artefact is `rsquaredacademy/rfm`, an R package for customer segmentation, at https://github.com/rsquaredacademy/rfm with its README read at https://raw.githubusercontent.com/rsquaredacademy/rfm/master/README.md. The repository has 69 stars, read from api.github.com. It is a statistics package rather than a prompt, but it states the method in three lines that an owner can follow without any software at all:
how recently a customer has purchased (recency) ... how often they purchase (frequency) ... how much the customer spends (monetary)
That is step 2, and the reason it was chosen over the fancier alternatives is that all three values come out of a till export and none of them is a prediction.
What we did not copy: the package's scoring machinery, which bins customers into quintiles and produces a three-digit RFM score such as 455. It is statistically respectable and it is useless to a publican, because nobody can read "segment 3-4-4" and know what to write to them. The skill keeps the three behaviours and throws away the scoring, replacing it with a rule stated in English that the owner can check against their own memory of the room. We also considered and rejected `Nikhilkohli1/Digital-Marketing-Analytics` (267 stars, read from api.github.com), which bundles RFM with attribution modelling and recommendation systems. That is a data science portfolio rather than a method a venue can run on a Tuesday, and importing its vocabulary would have made the output unreadable to the person who has to act on it.
Want this running in your business?
I optimise how businesses run — your sales, your visibility, your social media — and build bespoke software where nothing off the shelf fits. The first conversation is free. Work starts from £150 a day.
Foxera