# Application Email Generation Specification ## ADDED Requirements ### Requirement: Email Command Invocation The system SHALL provide a `/write-application-email` command that generates professional application emails with subject lines based on application context and profile information. #### Scenario: Command executed in application folder - **WHEN** user runs `/write-application-email` while in an application folder - **THEN** the system detects the current application automatically - **AND** generates email based on that application's data #### Scenario: Command executed with application name parameter - **WHEN** user runs `/write-application-email [application-name]` from any location - **THEN** the system locates the specified application folder - **AND** generates email based on that application's data #### Scenario: Command executed with --help flag - **WHEN** user runs `/write-application-email --help` - **THEN** the system displays usage information with examples - **AND** does not generate any email ### Requirement: Document Verification The system SHALL verify that all required documents exist in the `attachments/` folder before generating the application email. #### Scenario: All required documents present - **WHEN** CV and cover letter files exist in `attachments/` folder - **THEN** the system proceeds with email generation - **AND** includes references to these documents in the email body #### Scenario: Required documents missing - **WHEN** CV or cover letter files are missing from `attachments/` folder - **THEN** the system displays a clear error message listing missing documents - **AND** does not generate the email - **AND** provides guidance on where to place documents #### Scenario: Optional certificates present - **WHEN** certificate or diploma files exist in `attachments/` folder - **THEN** the system includes references to these documents in the email - **AND** mentions them in the document list ### Requirement: Email Content Generation The system SHALL generate email content with appropriate subject line, greeting, body, and closing based on application strategy and profile information. #### Scenario: Subject line generation - **WHEN** generating email for an application - **THEN** the subject line includes job title and applicant name - **AND** follows professional email conventions - **AND** matches the target language (German/English) #### Scenario: Email body with document references - **WHEN** generating email body - **THEN** the email includes a brief introduction - **AND** explicitly references attached documents (CV, cover letter) - **AND** mentions certificates/diplomas if present in attachments folder - **AND** expresses interest in the position - **AND** includes professional closing with contact information #### Scenario: Tone adaptation - **WHEN** application.md specifies tone (Formal/Balanced/Casual) - **THEN** the email adopts the appropriate language level - **AND** matches formality to company culture ### Requirement: Language Detection The system SHALL detect and apply the appropriate language (German or English) for the email based on application context. #### Scenario: German language application - **WHEN** job posting or application context indicates German - **THEN** the email is generated in German - **AND** uses appropriate German business email conventions - **AND** uses formal German addressing (Sie, Herr/Frau) #### Scenario: English language application - **WHEN** job posting or application context indicates English - **THEN** the email is generated in English - **AND** uses professional English business email conventions ### Requirement: File Management The system SHALL save generated email content to a markdown file in the application folder and handle file conflicts appropriately. #### Scenario: New email generation - **WHEN** `application-email.md` does not exist in application folder - **THEN** the system creates the file with generated content - **AND** displays success message with file location #### Scenario: Email already exists without force flag - **WHEN** `application-email.md` already exists - **AND** user did not provide `--force` flag - **THEN** the system displays error message - **AND** does not overwrite existing file - **AND** suggests using `--force` flag to overwrite #### Scenario: Email overwrite with force flag - **WHEN** `application-email.md` already exists - **AND** user provides `--force` or `--overwrite` flag - **THEN** the system overwrites the existing file - **AND** displays warning about overwriting - **AND** creates new email with generated content ### Requirement: Error Handling The system SHALL provide clear, actionable error messages when email generation cannot proceed. #### Scenario: Application folder not found - **WHEN** specified application folder does not exist - **THEN** the system displays error with list of available applications - **AND** provides example command syntax #### Scenario: Application data incomplete - **WHEN** application.md is missing required fields - **THEN** the system displays error indicating incomplete sections - **AND** suggests running `/populate-application` or manual completion #### Scenario: Profile data missing - **WHEN** profile.md cannot be read or is incomplete - **THEN** the system displays error message - **AND** suggests running `/validate-profile` - **AND** does not proceed with generation ### Requirement: Integration with Workflow The system SHALL integrate seamlessly with existing application workflow commands and validation. #### Scenario: Reads application strategy - **WHEN** generating email - **THEN** the system reads application.md for job details, company info, and tone - **AND** reads profile.md for applicant contact information - **AND** incorporates key messages from application strategy #### Scenario: References cover letter context - **WHEN** cover-letter.md exists in application folder - **THEN** the system ensures email tone and messaging align with cover letter - **AND** maintains consistency across all application documents ### Requirement: Output Format The system SHALL generate email in markdown format with metadata and clear structure. #### Scenario: Email file structure - **WHEN** email is generated - **THEN** the file includes metadata comment block (generation date, sources, language, tone) - **AND** contains subject line as heading - **AND** contains email body with proper paragraphs - **AND** includes signature block with applicant information #### Scenario: Email brevity - **WHEN** generating email body - **THEN** the content is concise (3-4 sentences maximum) - **AND** mentions attached documents explicitly - **AND** avoids redundancy with cover letter content