feat: add proposal for application email generation

Add OpenSpec proposal for /write-application-email command that:
- Generates professional application emails with subject lines
- Verifies documents exist in attachments/ folder before generation
- Updates /new-application to create attachments/ subfolder
- Follows similar pattern to /write-cover-letter command

Specs:
- application-email: 9 requirements for email generation
- application-management: 3 requirements for folder structure

OpenSpec: add-application-email

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-11-03 16:41:44 +01:00
co-authored by Claude
parent f85db4a2be
commit a4d390aa03
4 changed files with 325 additions and 0 deletions
@@ -0,0 +1,28 @@
# Add Application Email Generation
## Why
Users need a simple, automated way to compose professional application emails with proper subject lines and document references. Manually crafting these emails for every application is time-consuming and error-prone.
## What Changes
- Add `/write-application-email` command that generates email content and subject line
- Command verifies required documents exist in `attachments/` folder before generation
- Email references CV, cover letter, and optionally certificates/diplomas
- Update `/new-application` command to create `attachments/` subfolder with `.keep` file
- Follow similar implementation pattern to `/write-cover-letter` command
## Impact
**Affected specs:**
- `application-email` (new capability)
- `application-management` (modification to folder structure)
**Affected code:**
- `src/.claude/commands/new-application.md` - Add attachments folder creation
- `src/.claude/commands/write-application-email.md` - New command file
- `src/.claude/templates/` - Potentially new email template (if needed)
**Out of scope:**
- Creating or generating documents (CV, certificates) - must exist beforehand
- Attachment handling beyond verification
@@ -0,0 +1,176 @@
# 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
@@ -0,0 +1,63 @@
# Application Management Specification
## ADDED Requirements
### Requirement: Attachments Folder Creation
The system SHALL create an `attachments/` subfolder with a `.keep` file when initializing new applications to support document organization for email generation.
#### Scenario: Application folder creation includes attachments directory
- **WHEN** user runs `/new-application "Company - Job Title"`
- **THEN** the system creates folder structure: `applications/pending/[folder-name]/attachments/`
- **AND** creates an empty `.keep` file inside `attachments/` folder
- **AND** the attachments folder is ready for user to add documents
#### Scenario: Version control compatibility
- **WHEN** attachments folder is created with `.keep` file
- **THEN** the empty folder can be tracked in version control systems
- **AND** the folder structure is preserved even when empty
#### Scenario: Success message includes attachments folder
- **WHEN** new application is created successfully
- **THEN** the success message mentions the attachments folder
- **AND** provides guidance on what documents to place there
- **AND** indicates this folder is for CV, cover letter, certificates
### Requirement: Application Folder Structure
The system SHALL create a complete folder structure for each new application including metadata, input documents, and attachments.
#### Scenario: Complete folder structure created
- **WHEN** `/new-application` command is executed
- **THEN** the following structure is created:
```
applications/pending/[YYYY-MM-DD-Company-JobTitle]/
├── application.md
├── input/
└── attachments/
└── .keep
```
- **AND** application.md contains the template with metadata
- **AND** input/ folder is empty and ready for job posting documents
- **AND** attachments/ folder contains .keep file for version control
### Requirement: User Guidance for Attachments
The system SHALL provide clear guidance on the purpose and usage of the attachments folder.
#### Scenario: Attachments folder purpose explained
- **WHEN** new application is created
- **THEN** the success message explains attachments folder is for "final documents ready to send"
- **AND** distinguishes it from input/ folder (which is for "source materials and research")
- **AND** lists expected document types (CV, cover letter, certificates, diplomas)
#### Scenario: Workflow guidance includes attachments
- **WHEN** user views success message after creating application
- **THEN** the workflow guidance mentions adding documents to attachments/ after generation
- **AND** indicates attachments/ folder is checked by `/write-application-email` command
@@ -0,0 +1,58 @@
# Implementation Tasks
## 1. Update Application Folder Structure
- [ ] 1.1 Modify `src/.claude/commands/new-application.md` to create `attachments/` subfolder
- [ ] 1.2 Add creation of `.keep` file inside `attachments/` folder for version control
- [ ] 1.3 Update success message in new-application to mention attachments folder
- [ ] 1.4 Update test framework at `~/workspace/test-bewerbungen/` with new application structure
## 2. Create Email Generation Command
- [ ] 2.1 Create `src/.claude/commands/write-application-email.md` command file
- [ ] 2.2 Implement command argument parsing (application name, flags: --force, --help)
- [ ] 2.3 Implement location detection (current directory or parameter-based)
- [ ] 2.4 Add document verification logic (check for CV, cover letter, certificates in attachments/)
- [ ] 2.5 Implement email subject line generation based on job title and company
- [ ] 2.6 Implement email body generation with document references
- [ ] 2.7 Add language detection (German/English) similar to cover letter
- [ ] 2.8 Add tone adaptation (Formal/Balanced/Casual) from application.md
- [ ] 2.9 Implement file existence checks and user-friendly error messages
- [ ] 2.10 Write generated email to `application-email.md` in application folder
## 3. Testing & Quality Assurance
- [ ] 3.1 Test new-application creates attachments folder correctly
- [ ] 3.2 Test write-application-email with all required documents present
- [ ] 3.3 Test write-application-email with missing documents (error handling)
- [ ] 3.4 Test --force flag to overwrite existing email
- [ ] 3.5 Test language detection (German/English)
- [ ] 3.6 Test tone variations (Formal/Balanced/Casual)
- [ ] 3.7 Verify error messages are clear and actionable
## 4. Documentation
- [ ] 4.1 Update main CLAUDE.md with write-application-email command reference
- [ ] 4.2 Add email generation step to workflow documentation
- [ ] 4.3 Update example usage sections with email generation examples
- [ ] 4.4 Document attachments folder structure and purpose
## 5. Integration
- [ ] 5.1 Ensure email command integrates with existing validation workflow
- [ ] 5.2 Verify consistency with write-cover-letter command pattern
- [ ] 5.3 Test end-to-end workflow: new-application → populate → validate → cover-letter → email
## Dependencies
- Tasks 2.x depend on 1.x (attachments folder must exist)
- Tasks 3.x depend on 1.x and 2.x (implementation must be complete)
- Tasks 5.x depend on all previous tasks
## Verification Criteria
Each task is considered complete when:
- Code is written and tested
- Error cases are handled gracefully
- User-facing messages are clear and helpful
- Functionality matches specification