AgentSkillsCN

aem-architect

全面掌握 AEM(Adobe Experience Manager)的企业级架构设计技能。适用于构建 AEM 组件、设计内容架构、配置 Dispatcher 缓存、使用 Granite UI 创建对话框、实施 Sling 模型、OSGi 服务、Servlet 或 ClientLib 时使用。涵盖组件开发、性能优化、缓存策略、安全最佳实践,以及与 Cloud Manager 结合的 CI/CD 流程。同时支持 AEM 6.5 与 AEM as a Cloud Service。此外,还可为 AEM 系统生成架构图(Mermaid、ASCII)。适用于寻求 AEM 开发指导、组件创建、对话框设计、缓存配置、架构决策,或 AEM 项目中的架构图与可视化需求时使用。

SKILL.md
--- frontmatter
name: aem-architect
description: Comprehensive AEM (Adobe Experience Manager) architecture design skill for enterprise implementations. Use this skill when building AEM components, designing content architecture, configuring Dispatcher caching, creating dialogs with Granite UI, implementing Sling Models, OSGi services, servlets, or ClientLibs. Covers component development, performance optimization, caching strategies, security best practices, and CI/CD with Cloud Manager. Supports both AEM 6.5 and AEM as a Cloud Service. Also creates architecture diagrams (Mermaid, ASCII) for AEM systems. Triggers on requests for AEM development guidance, component creation, dialog design, caching configuration, architectural decisions, or diagram/visualization requests for AEM projects.

AEM Architect Skill

Enterprise-grade AEM solution design and implementation guidance.


Workflow Routing

Route to the appropriate workflow based on the request:

Request TypeWorkflowUse When
Diagrams/Visualizationsworkflows/AEMDiagrams.mdArchitecture diagrams, flowcharts, sequence diagrams, ASCII art
Component DevelopmentMain workflow belowBuilding new components, dialogs, HTL
Service/BackendMain workflow belowOSGi services, Sling Models, servlets
InfrastructureMain workflow belowDispatcher, caching, CI/CD

Diagram Request Detection

Use the AEMDiagrams workflow when the user mentions:

  • "diagram", "flowchart", "sequence diagram", "architecture diagram"
  • "visualize", "draw", "show me", "illustrate"
  • "mermaid", "ASCII art", "box diagram"
  • "component structure", "request flow", "cache flow"
  • "service dependencies", "class diagram", "state diagram"

Main Workflow

Follow this structured workflow for every AEM implementation request:

Phase 1: Requirements Gathering

Step 1.1: Ask for User Preference

First, ask the user:

"Would you like me to ask you some discovery questions to provide a more precise and tailored solution?

  • Yes - I'll ask targeted questions about your requirements
  • No - I'll proceed autonomously based on best practices and available context"

Step 1.2: Check for Attached Requirements

If the user has attached a file (.txt, .doc, .docx, or .md):

  1. Read and analyze the file for requirements
  2. Extract answers to the discovery questions below from the document
  3. If user accepted questions in Step 1.1, ask additional precision questions for any gaps or ambiguities found

Step 1.3: Discovery Questions (if user accepted)

Ask relevant questions from these categories:

Component Architecture

  • Component type? (content, structural, container, navigation)
  • Extend AEM Core Components or fully custom?
  • Required dialog fields? (text, image, pathfield, multifield, nested)
  • Target environment? (author, publish, or both)

Performance & Caching

  • Expected traffic volume? (low, medium, high, enterprise-scale)
  • Caching strategy? (aggressive, moderate, dynamic)
  • CDN integration required?

Integration

  • Headless/hybrid JSON APIs required?
  • External service integrations?
  • GraphQL for Content Fragments?
  • SPA framework integration?

Phase 2: Analysis & Planning

Step 2.1: Present High-Level Overview

After gathering requirements (or analyzing autonomously), present:

Understanding Summary

Based on my analysis, here's what I understand about your requirements:

  • [Bullet points summarizing the project scope]
  • [Target environment and architecture]
  • [Key components and features needed]
  • [Performance and caching considerations]
  • [Integration points]

Step 2.2: Present TODO List

Create and present a numbered task list:

Implementation Plan

I will implement the following tasks:

  1. Task 1: Description
  2. Task 2: Description
  3. Task 3: Description ...

Would you like to proceed with this plan, or do you have any changes to propose?

Step 2.3: Wait for User Approval

  • If user approves → Proceed to Phase 3
  • If user proposes changes → Update the plan and present again
  • Do NOT start implementation until user confirms

Phase 3: Implementation

Execute the approved TODO list:

  1. Create component structure
  2. Implement Sling Model with proper injectors
  3. Design dialog using Granite UI patterns
  4. Configure ClientLibs with bundling strategy
  5. Set up Dispatcher rules
  6. Provide testing guidance

Phase 4: Validation

Present completed work with:

  • Summary of what was implemented
  • File locations and structure
  • Testing recommendations
  • Cloud Manager quality gate considerations

Reference Documentation

Read the appropriate reference based on the task:

Workflows

WorkflowFileUse When
AEM Diagramsworkflows/AEMDiagrams.mdCreating Mermaid or ASCII architecture diagrams

Core References (in this skill)

TopicFileUse When
Architecture Patternsreferences/architecture-deep-dive.mdDesigning system architecture, scaling, MVC patterns
Cloud Servicereferences/cloud-service-guidelines.mdDeveloping for AEMaaCS, cluster-aware code, state management
Dialog Fieldsreferences/dialog-field-types.mdCreating component dialogs with Granite UI
Dispatcherreferences/dispatcher-configuration.mdConfiguring filters, caching, load balancing
Performancereferences/performance-optimization.mdOptimizing ClientLibs, Sling Models, caching
Sling Jobsreferences/sling-jobs.mdBackground task scheduling for Cloud Service
Testing Patternsreferences/testing-patterns.mdUnit testing with AEM Mocks, JUnit 5
Anti-Patternsreferences/anti-patterns.mdCommon mistakes and how to fix them
Code Snippetsreferences/code-snippets.mdCopy-paste ready code templates

External Guides (in project root)

TopicFileUse When
Sling Modelsaem-sling-models-guide.mdModel patterns, injectors, exporters
OSGi Servicesaem-osgi-services-guide.mdService design, dependency injection
Servletsaem-servlets-guide.mdEndpoint patterns, security
Dialogsaem-dialog-creation-guide.mdGranite UI, multifields, validation
ClientLibsaem-clientlibs-guide.mdJS/CSS bundling, lazy loading
Dispatcheraem-dispatcher-guide.mdDetailed cache configuration
Componentscomponent-development.mdHTL, component structure
Best Practicesadobe-technical-practices.mdAdobe-recommended patterns

Quick Reference: Component Creation

Component Structure

code
/apps/myproject/components/mycomponent/
├── .content.xml                    # Component definition
├── _cq_dialog/.content.xml         # Author dialog
├── _cq_editConfig.xml              # Edit configuration
├── mycomponent.html                # HTL template
└── clientlib/                      # Component CSS/JS

Component Definition

xml
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:jcr="http://www.jcp.org/jcr/1.0"
    xmlns:cq="http://www.day.com/jcr/cq/1.0"
    xmlns:sling="http://sling.apache.org/jcr/sling/1.0"
    jcr:primaryType="cq:Component"
    jcr:title="My Component"
    jcr:description="Description"
    componentGroup="My Project - Content"
    sling:resourceSuperType="core/wcm/components/title/v3/title"/>

Sling Model Pattern

java
@Model(
    adaptables = {Resource.class, SlingHttpServletRequest.class},
    adapters = {MyComponent.class, ComponentExporter.class},
    resourceType = MyComponentImpl.RESOURCE_TYPE,
    defaultInjectionStrategy = DefaultInjectionStrategy.OPTIONAL
)
@Exporter(name = ExporterConstants.SLING_MODEL_EXPORTER_NAME,
          extensions = ExporterConstants.SLING_MODEL_EXTENSION)
public class MyComponentImpl implements MyComponent {

    static final String RESOURCE_TYPE = "myproject/components/mycomponent";

    @ValueMapValue
    private String title;

    @OSGiService
    private MyService myService;

    @Override
    public String getTitle() { return title; }
}

Common Dialog Fields

FieldResource Type
Textgranite/ui/components/coral/foundation/form/textfield
Textareagranite/ui/components/coral/foundation/form/textarea
Rich Textcq/gui/components/authoring/dialog/richtext
Checkboxgranite/ui/components/coral/foundation/form/checkbox
Selectgranite/ui/components/coral/foundation/form/select
Pathgranite/ui/components/coral/foundation/form/pathfield
Imagecq/gui/components/authoring/dialog/fileupload
Multifieldgranite/ui/components/coral/foundation/form/multifield

For complete field examples, see references/dialog-field-types.md.

Caching Decision Tree

code
Is content personalized?
├── YES → No Dispatcher cache
│         └── Use client-side personalization or ESI
└── NO → Cache at Dispatcher
         ├── Static asset (JS/CSS/images)?
         │   └── Long TTL (1 year) + content-hash
         ├── HTML content?
         │   └── Moderate TTL (5-60 min) + statfileslevel
         └── API/JSON?
             ├── Public → TTL based on freshness needs
             └── Private → No Dispatcher cache

Statfileslevel Reference

StructureLevelEffect
/content/site2Per-site invalidation
/content/site/language3Per-language invalidation
/content/site/region/country4Per-country invalidation

Security Checklist

Dispatcher Filters (Default Deny)

apache
/filter {
    /0001 { /type "deny" /glob "*" }
    /0100 { /type "allow" /method "GET" /url "/content/mysite/*" }
    /0200 { /type "allow" /method "GET" /url "/etc.clientlibs/*" }
    /0300 { /type "allow" /method "GET" /url "/content/dam/*" }
    /0900 { /type "deny" /url "/bin/*" }
    /0901 { /type "deny" /url "/system/*" }
    /0902 { /type "deny" /url "*.infinity.json" }
}

Service User Pattern

java
try (ResourceResolver resolver = resolverFactory.getServiceResourceResolver(
        Map.of(ResourceResolverFactory.SUBSERVICE, "myproject-service-user"))) {
    // Minimal permissions operations
}

Cloud Service Specifics

When developing for AEMaaCS, always read references/cloud-service-guidelines.md for:

  • Cluster-aware code: Instances can stop anytime
  • No local state: Disk is ephemeral
  • Sling Jobs: For reliable background tasks
  • HTTP timeouts: Always set connect/read timeouts
  • Rate limiting: Handle 429 with exponential backoff
  • Touch UI only: No Classic UI support
  • Immutable repository: /libs and /apps are read-only

CI/CD Quality Gates

GateChecksAction
Code QualitySonarQube, code smellsFix before merge
SecurityVulnerability scanImmediate fix
PerformanceLoad test, response timesReview if fails

Common Pitfalls

  1. JCR queries in render path → Use content hierarchy traversal
  2. Hardcoded paths → Use context-aware configuration
  3. Unclosed ResourceResolvers → Use try-with-resources
  4. Deep multifield nesting → Consider child nodes
  5. Missing Dispatcher filters → Default-deny approach
  6. Admin sessions in code → Use service users
  7. Untested cache invalidation → Verify statfileslevel
  8. Large inline dependencies → Lazy load heavy scripts
  9. Skipping Core Components → Extend before building custom
  10. Ignoring Cloud Manager gates → Fix locally first