# AI Knowledge Base Drafting

## Objective

Turn a solved support issue into a help article draft a writer can finish.

A structured, unpublished help article draft generated from a resolved ticket or a set of product notes, with unverified content marked and customer details removed.

## Before You Begin

This feature is being added to an application that already exists and already
works. Do not scaffold a new project, and do not assume a blank slate.

Inspect the codebase first and establish:

- The existing application structure and where code of this kind already lives.
- The framework and version in use.
- The existing design system — colours, spacing, typography, and component conventions.
- Existing UI components you can reuse instead of writing new ones.
- The existing database structure, if this feature needs to persist anything.
- The existing authentication and authorization system, if this feature is user-scoped.
- Dependencies already installed, so you don't add a library that duplicates one.
- The existing test setup and conventions.

Only start writing code once you understand the above. If the application
already implements part of this feature, extend it rather than replacing it.

## Implementation Instructions

1. Take a resolved ticket thread or a set of product notes as input and produce a draft in the app's existing article structure — title, summary, prerequisites, steps, related links — rather than one block of prose.
2. Strip customer identity before the content is sent anywhere: names, addresses, account identifiers, order numbers, and anything else that identifies the person or their organisation. Remove it at the point the input is assembled.
3. Mark the steps that were confirmed to resolve the issue separately from the ones that were tried and abandoned during troubleshooting. A draft that presents a failed experiment as instruction is worse than no draft.
4. Pass the app's current feature names and interface labels in as reference material and require the draft to use them, so articles do not describe screens with names the product stopped using.
5. Create the article in draft state only, in the app's existing publishing workflow. This brief produces long-form articles from solved issues; short question-and-answer pairs from an already-approved document belong to AI FAQ Generator.

## UI and UX Requirements

Match the application's existing design system exactly. Reuse its components,
spacing, and typography. This feature should look like it was always there.

## Responsive Requirements

Works on mobile, tablet, and desktop. Touch targets are large enough to hit on a
phone, and nothing overflows horizontally at 320px.

## Accessibility Requirements

- Fully keyboard navigable.
- Correct semantic elements and ARIA roles.
- Visible focus states.
- Meets WCAG AA contrast.
- Dynamic changes are announced to screen readers.
- Respects prefers-reduced-motion.

## Edge Cases

- One customer's ticket becomes public documentation here. Any residual identifying detail — a company name in a log line, an email in a screenshot path — is a disclosure, so redaction must run before generation and be checked after it.
- Troubleshooting threads are full of dead ends. Steps that did not work must be excluded or clearly labelled, and the draft must state which sequence was actually verified to fix the problem.
- Stale terminology makes an article unusable even when the steps are right. If a label in the draft does not match anything in the current product, flag it for the writer rather than publishing it.
- Screenshots and interface captures cannot be generated. Mark the places one is needed with a note on what it should show, and leave the gap visible rather than describing an image that does not exist.
- Nothing generated here reaches customers without a human publishing it. Draft state is the default and there is no automatic publish path.
- A refusal, timeout, or malformed structure must leave no partial article behind. Either the full draft is created or the attempt is discarded with an error the requester can see.
- A ticket containing credentials, tokens, or configuration secrets must be refused as an input rather than redacted and used.
- Enforce a length ceiling and a per-workspace limit on drafting runs so a bulk import of resolved tickets cannot generate hundreds of articles at unbounded cost.

## Testing

Exercise the feature end to end in the running application. Cover every edge case
above, then run the existing test suite and confirm nothing regressed.

## Acceptance Criteria

- [ ] Drafts follow the app's existing article structure rather than arriving as undifferentiated prose.
- [ ] Customer-identifying and confidential details are removed before generation and verified absent after.
- [ ] Verified resolution steps are distinguished from abandoned troubleshooting attempts.
- [ ] Product names and interface labels match the current product, with mismatches flagged for the writer.
- [ ] Places requiring a human-captured screenshot are marked with what the image should show.
- [ ] Articles remain in draft until a person publishes them, with no automatic publish path.
- [ ] Drafting runs are capped per workspace and produce no partial article on failure.
- [ ] The feature matches the existing design system.
- [ ] No existing functionality is broken.

## Adaptation Rules

- Match the existing design system. Do not introduce a new colour palette,
  spacing scale, or component library.
- Reuse existing components and utilities wherever they fit.
- Follow the naming, file layout, and code style already present.
- Do not upgrade, replace, or remove existing dependencies to make this
  feature fit. Adapt the feature to the app, not the app to the feature.
- Do not break existing functionality. If a change is genuinely required in
  existing code, make the smallest one that works and say so.
- If something in these instructions conflicts with how the application is
  built, follow the application and explain the deviation.

## Final Verification

Before you report the work as done:

1. Re-read the acceptance criteria above and check each one against what you
   actually built.
2. Run the application and exercise the feature end to end.
3. Run the existing test suite and confirm you have broken nothing.
4. Check the feature on mobile, tablet, and desktop widths.
5. Check keyboard navigation and focus handling.
6. Summarize what changed: files added, files modified, and anything you
   deliberately did differently because of how this application is built.

If any acceptance criterion is unmet, fix it before reporting completion.
