--- name: AEM Development Workflow description: Required workflow for AEM EDS development - linting, testing, preview validation, and PRs with demo links. Use when developing blocks or features for AEM Edge Delivery Services projects, before doing anything else. --- # AEM Development Workflow ## Overview **AEM Edge Delivery Services has a required development workflow with non-negotiable quality gates.** These gates ensure code works in production, not just locally. Skipping gates under pressure leads to broken demos, failed builds, and technical debt. ## The Required Workflow ``` 1. Define Content Structure 2. Request Real CMS Content (human creates in parallel) 3. Create Local HTML 4. Implement Block 5. Lint 6. Test Locally (with HTML) 7. Push Feature Branch 8. Test in Preview (with real CMS content) 9. Open PR with Demo Link (real content) 10. Validate PR Checks Pass ``` **Every step is required. No exceptions.** **Critical:** AEM EDS is content-first. You request real CMS content BEFORE implementing, then use local HTML for rapid development. PR must use real authored content. ## The Non-Negotiable Gates ### 1. Linting MUST Pass Before Commit ```bash npm run lint ``` **If linting fails, fix it.** Don't commit. **Common rationalizations to ignore:** - ❌ "Just style issues, functionality works" - ❌ "Client is waiting, I'll fix later" - ❌ "Linting is too slow" **Reality:** Linting takes 10-30 seconds. Lint failures can break builds. Fix it now. --- ### 2. Test Content MUST Exist Before Implementation **Content-first approach:** Define content structure and create (or locate) test content BEFORE implementing the block. **Two types of test content:** **A. Local HTML for Development (You create)** - Static HTML file matching AEM's HTML structure - Used with `aem up --html-folder=./drafts/agent` (or `npx aem up --html-folder=./drafts/agent`) - Lives in project's `drafts/agent/` folder - Allows rapid local development iteration - **Not sufficient for PR** - this is for your development only **B. Real Authored Content for PR (Human creates in CMS)** - Word/Google Doc created by human in the CMS - Published to `/drafts/` folder (e.g., `/drafts/testimonials-test`) - Required for PR demo link - Shows block works with real author workflow **The workflow:** 1. **Before implementation:** Ask human to create real test content in CMS - "Can you create test content at /drafts/[block-name]-test with [structure description]?" - This happens in PARALLEL while you implement 2. **During implementation:** Create local HTML in drafts/agent/ to match that structure - Faster iteration during development - Must match the structure of what authors will create 3. **For PR:** Use the real CMS content path (in /drafts/) for demo link **Common rationalizations to ignore:** - ❌ "I'll implement first, then request content" - ❌ "Local HTML is enough for the PR" (NO - must use real authored content) - ❌ "It's simple, doesn't need real content" - ❌ "I'll create content in the CMS myself" (NO - let authors create it) **Reality:** You need BOTH. Local HTML for fast development, real CMS content for PR validation. --- ### 3. Feature Branch Workflow Always ```bash git checkout -b feature/block-name git add blocks/block-name/ git commit -m "Add block-name block" git push origin feature/block-name ``` **Never push directly to main.** Feature branches enable: - Automatic preview environments - Parallel development - Clean rollback if needed **Common rationalizations to ignore:** - ❌ "Pushing to main saves time" - ❌ "It's a small change" - ❌ "I'm the only developer" **Reality:** Direct-to-main pushes skip preview validation and break the workflow. --- ### 4. Preview Validation Required AEM EDS automatically creates preview URLs when you push a feature branch: ``` https://branch--repo--org.aem.page/your-test-page ``` **You MUST validate in preview before sharing the link:** 1. Push feature branch 2. Wait for preview build (usually < 30 seconds) 3. Open preview URL and verify block works 4. **Then** share the link **Common rationalizations to ignore:** - ❌ "Works locally, will work in preview" - ❌ "Client is waiting, send it now" - ❌ "I'll validate after sharing" **Reality:** Never send a link you haven't validated. Broken demos are worse than waiting 30 seconds. --- ### 5. PR with Demo Link Required Create PR with: 1. Clear title describing what changed 2. **Working preview link** showing the block in action 3. Brief description of implementation **Example PR description:** ```markdown ## Testimonials Block Adds customer testimonial display block. **Preview:** https://feature-testimonials--myproject--adobe.aem.page/test-testimonials - Responsive card layout - Supports multiple testimonials - Mobile-optimized design ``` **Common rationalizations to ignore:** - ❌ "Code is self-explanatory" - ❌ "PR process is too slow" - ❌ "No one reviews PRs anyway" **Reality:** PRs document changes and provide demo links for stakeholders. --- ## The Complete Workflow ### Step-by-Step **1. Define Content Structure (5-10 min)** - Determine what content structure authors will use - Consider: tables, lists, simple paragraphs - Make it author-friendly (they use Word/Google Docs) - Document expected structure **2. Request Real Test Content from Human (1 min)** Ask your human partner to create test content in the CMS in PARALLEL: ``` "Can you create test content at /drafts/[block-name]-test? It should have [describe structure: e.g., 'a table with 2 columns: testimonial text in first column, author name in second column. Include 3-4 example testimonials.'] I'll create local HTML in /drafts/agent/ to match this structure for development." ``` This happens in parallel while you implement - don't wait for them to finish. **3. Create Local HTML for Development (5 min)** ```bash # Create test HTML matching AEM structure in drafts/agent folder mkdir -p drafts/agent # Create HTML file with structure matching step 1 # e.g., drafts/agent/testimonials-test.html ``` The local HTML: - Must match AEM's HTML output structure (check existing blocks for examples) - Lives in `drafts/agent/` folder - Used for rapid development iteration - NOT used for PR **CRITICAL HTML Structure Requirements:** Your HTML must include the proper block decoration structure for blocks to load. **IMPORTANT:** Always check `head.html` in your project root and copy those exact script/style includes into your test HTML. This ensures you have the correct nonce attributes, CSP headers, and script references. **Template structure:** ```html