Token导航 LogoToken导航TokenDH.com
前端设计需要联网github未标认证来源可访问许可证需确认审计通过

compose-arch组成拱门

Agent Skill

compose-arch 用于处理 GitHub 仓库、Issue、Pull Request 和代码协作信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要围绕仓库状态、代码变更或协作事项进行整理时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

188

周安装

8

GitHub Stars

2

下载量

66
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:compose-arch(组成拱门)
来源仓库:https://github.com/andvl1/claude-plugin
仓库路径:skills/compose-arch
安装命令:
npx skills add https://github.com/andvl1/claude-plugin --skill compose-arch
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/andvl1/claude-plugin --skill compose-arch

简介

compose-arch 建立 Compose Multiplatform 严格架构规则的单真相源。

  • 适用于跨平台 UI 开发中强制实施关注点分离的场景。
  • 采用 Screen/View/Component 分层结构,确保各层职责清晰明确。
  • 与 kmp-feature-slice、kotlin-web 等技能共享相同架构约束。
  • 使用时必须严格遵守图层分离原则,禁止跨层直接访问。

SKILL.md

Compose Multiplatform Architecture Framework

SINGLE SOURCE OF TRUTH for Compose Multiplatform architecture rules. All agents and skills reference this file — do not duplicate these rules elsewhere.

Strict architectural patterns for building Compose Multiplatform features using feature slices. Enforces separation of concerns through Screen/View/Component layering.

Related skills:

  • kmp-feature-slice — procedural feature generation workflow (uses this skill's rules)
  • kotlin-web — web frontend patterns (Compose WASM follows these same rules)

Core Principles

Layer Separation (STRICT)

LayerResponsibilityRules
ScreenThin adapterReads viewState, passes to View. NO logic, NO remember, NO calculations
ViewPure UIOnly layout, only viewState, only eventHandler. NO side effects
ComponentAll logicState, events, use cases, lifecycle. Uses Decompose
DomainBusinessUse cases, repositories, data sources

Screen Layer

File: <FeatureName>Screen.kt

@Composable
fun FeatureScreen(component: FeatureComponent) {
    val viewState by component.viewState.subscribeAsState()
    FeatureView(viewState, component::obtainEvent)
}

Screen Rules

  • Maximum: 1000 lines (hard limit)
  • Recommended: Under 600 lines
  • Forbidden:

- Business logic - Navigation logic - State management - remember calls - Calculations

View Layer

File: <FeatureName>View.kt

@Composable
fun FeatureView(
    viewState: FeatureViewState,
    eventHandler: (FeatureEvent) -> Unit
) {
    // Only layout and viewState rendering
    Column(modifier = Modifier.fillMaxSize()) {
        when (viewState) {
            is FeatureViewState.Loading -> LoadingContent()
            is FeatureViewState.Success -> SuccessContent(
                data = viewState.data,
                onItemClick = { eventHandler(FeatureEvent.ItemClicked(it)) }
            )
            is FeatureViewState.Error -> ErrorContent(
                message = viewState.message,
                onRetry = { eventHandler(FeatureEvent.Retry) }
            )
        }
    }
}

View Rules

  • Only layout code
  • Only work with viewState
  • Only call eventHandler
  • NO logic
  • NO remember
  • NO side effects
  • NO previews in production code

UI Guidelines

  • Maximum nesting depth: 3 levels
  • Spacing: multiples of 8/16/24 dp
  • Use theme: AppTheme.colors, AppTheme.typography
  • Use theme icons consistently
  • Extract to common/ui/ if used in 5+ places

Component Layer

File: <FeatureName>Component.kt

interface FeatureComponent {
    val viewState: Value<FeatureViewState>
    fun obtainEvent(event: FeatureEvent)
}

@Inject
class DefaultFeatureComponent(
    private val getDataUseCase: GetDataUseCase,
    @Assisted componentContext: ComponentContext,
    @Assisted private val onNavigate: (String) -> Unit
) : FeatureComponent, ComponentContext by componentContext {

    private val _viewState = MutableValue<FeatureViewState>(FeatureViewState.Loading)
    override val viewState: Value<FeatureViewState> = _viewState

    private val scope = componentScope()

    init { loadData() }

    override fun obtainEvent(event: FeatureEvent) {
        when (event) {
            is FeatureEvent.ItemClicked -> onNavigate(event.itemId)
            is FeatureEvent.Retry -> loadData()
        }
    }

    private fun loadData() {
        scope.launch {
            _viewState.value = FeatureViewState.Loading
            getDataUseCase.execute()
                .onSuccess { _viewState.value = FeatureViewState.Success(it) }
                .onError { msg, _ -> _viewState.value = FeatureViewState.Error(msg) }
        }
    }

    @AssistedFactory
    interface Factory : FeatureComponent.Factory
}

Component Rules

  • Single source of logic
  • Stores state (Value<T> from Decompose)
  • Handles all events
  • Executes use cases
  • Manages lifecycle
  • Navigation ONLY through Decompose:

- StackNavigation / childStack - SlotNavigation / childSlot

Component Dependencies

Allowed:

  • Use cases
  • Repositories (indirectly via use cases)
  • Platform drivers (via DI)

Forbidden:

  • Direct data source access
  • UI imports (Compose)

Use Case Layer

File: <FeatureName><Action>UseCase.kt

@Inject
class GetFeatureDataUseCase(
    private val repository: FeatureRepository
) {
    suspend fun execute(params: Params): Result<FeatureData> {
        return try {
            val data = repository.getData(params.id)
            Result.success(data)
        } catch (e: Exception) {
            Result.failure(e)
        }
    }
}

Use Case Rules

  • One class per file
  • Returns only Result<T>
  • Single execute(params): Result<T> function
  • NOT an operator function
  • All error handling happens here
  • Dependencies:

- Repository - TokenManager (if needed) - Platform drivers (if needed) - Other UseCases (rarely, for reuse)

Repository Layer

File: <FeatureName>Repository.kt

@Inject
class FeatureRepository(
    private val localDataSource: FeatureLocalDataSource,
    private val remoteDataSource: FeatureRemoteDataSource
) {
    suspend fun getData(id: String): FeatureData {
        return try {
            remoteDataSource.fetch(id)
        } catch (e: Exception) {
            localDataSource.get(id) ?: throw e
        }
    }

    suspend fun saveData(data: FeatureData) {
        localDataSource.save(data)
        remoteDataSource.sync(data)
    }
}

Repository Rules

  • Concrete class (no interfaces needed for internal repos)
  • Dependencies: only DataSources
  • Returns clean data
  • Coordinates local/remote sources

DataSource Layer

Files:

  • <FeatureName>LocalDataSource.kt
  • <FeatureName>RemoteDataSource.kt
@Inject
class FeatureLocalDataSource(
    private val database: AppDatabase
) {
    suspend fun get(id: String): FeatureData? {
        return database.featureDao().getById(id)?.toDomain()
    }

    suspend fun save(data: FeatureData) {
        database.featureDao().insert(data.toEntity())
    }
}

@Inject
class FeatureRemoteDataSource(
    private val apiClient: ApiClient
) {
    suspend fun fetch(id: String): FeatureData {
        return apiClient.get("/features/$id").body<FeatureDto>().toDomain()
    }
}

DataSource Rules

  • Simple provider pattern
  • Dependencies:

- Local storage (Room, DataStore) - Platform APIs - Network client (Ktor)

ViewState and Events

File: <FeatureName>ViewState.kt

sealed class FeatureViewState {
    data object Loading : FeatureViewState()
    data class Success(val data: List<FeatureItem>) : FeatureViewState()
    data class Error(val message: String) : FeatureViewState()
}

File: <FeatureName>ViewEvent.kt

sealed class FeatureEvent {
    data class ItemClicked(val itemId: String) : FeatureEvent()
    data object Retry : FeatureEvent()
    data object BackPressed : FeatureEvent()
}

File Rules (HARD)

One class per file:

  • Screen → separate file
  • View → separate file
  • ViewState → separate file
  • ViewEvent → separate file
  • Component → separate file
  • UseCase → separate file (each)
  • Repository → separate file
  • DataSource → separate file (each)

NO god files - split immediately if file grows beyond responsibility.

Feature Directory Structure

feature/<featureName>/
├── api/                          # Public interfaces
│   └── src/commonMain/kotlin/
│       ├── <Name>Component.kt    # Interface only
│       ├── <Name>Models.kt       # Domain models
│       └── <Name>Repository.kt   # Interface (if public)
│
└── impl/                         # Implementation
    └── src/commonMain/kotlin/
        ├── screen/
        │   └── <Name>Screen.kt
        ├── view/
        │   ├── <Name>View.kt
        │   ├── <Name>ViewState.kt
        │   └── <Name>ViewEvent.kt
        ├── component/
        │   └── Default<Name>Component.kt
        ├── domain/
        │   ├── usecase/
        │   │   ├── Get<Name>UseCase.kt
        │   │   └── Update<Name>UseCase.kt
        │   └── repository/
        │       └── <Name>Repository.kt
        ├── data/
        │   └── datasource/
        │       ├── <Name>LocalDataSource.kt
        │       └── <Name>RemoteDataSource.kt
        └── di/
            └── <Name>Module.kt

DI Module

File: <FeatureName>Module.kt

@BindingContainer
class FeatureModule {
    @Provides
    fun provideFeatureRepository(
        localDataSource: FeatureLocalDataSource,
        remoteDataSource: FeatureRemoteDataSource
    ): FeatureRepository = FeatureRepository(localDataSource, remoteDataSource)
}

Code Rules

RuleDetails
SerializationOnly Kotlinx Serialization
JSONSingle instance via DI
Repository returnClean domain data
UseCase returnAlways Result<T> (or Result<Flow<T>>)
Error handlingAll in UseCase (where Result is created)
StateNever use remember in View - state from Component

Common Components

Extract to common/ui/<ComponentName>.kt when:

  • Used in 5+ locations
  • Generic enough for reuse
  • No feature-specific logic
// common/ui/LoadingButton.kt
@Composable
fun LoadingButton(
    text: String,
    loading: Boolean,
    onClick: () -> Unit,
    modifier: Modifier = Modifier
) {
    Button(
        onClick = onClick,
        enabled = !loading,
        modifier = modifier
    ) {
        if (loading) {
            CircularProgressIndicator(
                modifier = Modifier.size(16.dp),
                strokeWidth = 2.dp
            )
        } else {
            Text(text)
        }
    }
}

Validation Checklist

Before completing a feature, verify:

  • Screen has no business logic
  • View has no remember/side effects
  • Component handles all logic
  • All navigation in Component via Decompose
  • UseCases return Result
  • One class per file
  • No god files
  • UI nesting <= 3 levels
  • Spacing uses 8/16/24 multiples
  • Common components extracted if 5+ uses

Anti-Patterns to Avoid

Anti-PatternCorrect Pattern
Logic in ScreenMove to Component
remember in ViewState from Component
Direct API calls in ComponentUse UseCase
UseCase calling DataSourceUse Repository
God file with multiple classesSplit to separate files
Deep nesting (4+ levels)Extract sub-components
Hardcoded colors/dimensionsUse theme

Resources

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

34.47%
按下载量换算23

Claude

31.74%
按下载量换算21

Cursor

17.97%
按下载量换算12

Gemini CLI

9.41%
按下载量换算6

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills