FFCA Cross-Feature
Workflow for the moment one feature needs another. The patterns live in ${CLAUDE_PLUGIN_ROOT}/references/ffca/: read the cited sections before coupling two features.
The two allowed couplings
Features couple in exactly two places, and in one direction each:
- Domain to domain. A consuming feature's domain may depend on a provider feature's domain, for example
cart_domain on product_domain. Read ${CLAUDE_PLUGIN_ROOT}/references/ffca/domain.md, section Composing features.
- Presentation to presentation. A presentation package may use a public widget from another feature's presentation package, under the three conditions below. Read
${CLAUDE_PLUGIN_ROOT}/references/ffca/presentation.md, section Sharing a widget across features.
Data layers never reach across features for data, and no layer ever depends on another feature's data package.
Sharing data
- Loose coupling by id: the Summary pattern. When a feature stores references to another feature's models, store ids only. The read model holds full objects (
Cart with List<Product>); the stored summary holds ids (CartSummary with List<String>). The repository reads and writes summaries and only takes the full object when one is being created. Read ${CLAUDE_PLUGIN_ROOT}/references/ffca/domain.md, section Storing data, and adapt the shapes in ${CLAUDE_PLUGIN_ROOT}/references/code_templates/domain_templates.md.
- Combine repositories with a Query. To assemble a populated model from two features, add a
Query in the consuming feature's domain that takes both repository interfaces. Read ${CLAUDE_PLUGIN_ROOT}/references/ffca/domain.md, section Reading the populated object. Keep the Query in the consumer, never in the provider: the cart feature never learns how products are stored, and the product feature never learns that carts exist.
- Normalize inside the repository, not a Query. When an API returns nested objects belonging to another feature, split them inside the data repository, which may depend on another feature's domain interface. Read
${CLAUDE_PLUGIN_ROOT}/references/ffca/faq.md, section Dealing with nested objects. The DTO-to-domain mapping is duplicated in the consuming data package on purpose: DRY is traded for bounded contexts here deliberately.
Do not call these classes "use cases". They are Commands and Queries. See ${CLAUDE_PLUGIN_ROOT}/references/ffca/domain.md, section Business rules.
Sharing a widget
A widget that owns a Cubit is not a separate feature. It lives in its own feature's presentation package and is exported through a barrel. Two ways to get it onto another feature's screen, and the choice is about who places it.
Direct import behind a narrow barrel. Three conditions, all from ${CLAUDE_PLUGIN_ROOT}/references/ffca/presentation.md, section Sharing a widget across features:
- The widget gets its own barrel. Consumers import
package:cart_presentation/cart_badge.dart, never the primary cart_presentation.dart barrel.
- The barrel stays narrow. Its transitive imports must not reach the feature's modules or screens. Going through the primary barrel costs the consumer every screen and Cubit the feature owns, and it breaks deferred loading downstream.
- No cycles. If two features each need a widget from the other, extract the shared part downward into a third package instead of importing sideways.
A slot the app fills. The consuming feature never learns the other feature exists: it declares a nullable Widget parameter and the app supplies it. Same inversion as navigation. Name the slot for its position (trailingAction), default it to nothing, and stop at two slots per module. Read ${CLAUDE_PLUGIN_ROOT}/references/ffca/presentation.md, section Or let the app place it.
Choosing. Use a slot when the widget is app chrome, such as a cart badge in an app bar, which belongs to the shell rather than to the screen around it. Use a direct import when the widget is genuinely part of what the consuming screen is. Read ${CLAUDE_PLUGIN_ROOT}/references/ffca/presentation.md, section Choosing between them.
Where a shared widget should live
When the same widget is wanted in more than one feature, work through ${CLAUDE_PLUGIN_ROOT}/references/ffca/presentation.md, section Where the widget should live, in order:
- Does it need a repository or a domain type? If not, it is a pure presentational component and belongs in
ui_kit. This test is mechanical, not stylistic: shared packages depend on external packages only, so a widget that needs a repository cannot compile there.
- If it does, split it. The view taking a plain count goes in
ui_kit; the Cubit plus that view stays in its feature behind its own barrel. A widget that genuinely gets reused across features is usually a presentational leaf with the stateful part left behind, which means the pressure was pointing at ui_kit all along.
When a Query is not enough: compose a feature
If multi-domain logic grows its own models, screens, or lifecycle, create a feature for it. Read ${CLAUDE_PLUGIN_ROOT}/references/ffca/overview.md, sections Features and Presentation-only features. A feature that composes several other domains into a screen without owning business logic is a presentation-only feature: a {name}_presentation package with no domain or data sibling, depending on the other features' domains.
Identity versus entity
Auth and user profile are separate domains, not one. Read ${CLAUDE_PLUGIN_ROOT}/references/ffca/faq.md, section How do I handle auth and user profiles? Keep AuthUser in auth_domain and UserProfile in user_profile_domain, and glue them with a Query in the consuming domain, so a new profile field never forces a change to auth.
1---2name: ffca-cross-feature3description: >4 Cross-feature dependencies in FFCA: the Summary pattern, Queries that combine repositories,5 sharing widgets between features, widget slots, and composing features. Use in an FFCA monorepo,6 a features/ folder whose packages are named {feature}_domain, {feature}_data, and7 {feature}_presentation, when one feature needs data, behavior, or a widget from another, when8 sharing models or widgets across features, or when choosing between a Query, a widget slot, and a9 new composing feature. Triggers on "feature A needs data from feature B", "can cart import10 checkout", "share this model between features", "reuse this widget in another feature", "how do11 features talk to each other", "should this be a use case or a new feature", "combine two12 repositories", and "avoid a circular dependency between features". If the repo instead uses13 packages/ with _repository and _api_client packages, defer to vgv-ai-flutter-plugin's14 layered-architecture skill.15allowed-tools: Read Glob Grep16effort: high17metadata:18 source: https://skillmd.com/skills/verygoodopensource/ffca-cross-feature19---2021# FFCA Cross-Feature2223Workflow for the moment one feature needs another. The patterns live in `${CLAUDE_PLUGIN_ROOT}/references/ffca/`: read the cited sections before coupling two features.2425## The two allowed couplings2627Features couple in exactly two places, and in one direction each:2829- **Domain to domain.** A consuming feature's domain may depend on a provider feature's domain, for example `cart_domain` on `product_domain`. Read `${CLAUDE_PLUGIN_ROOT}/references/ffca/domain.md`, section *Composing features*.30- **Presentation to presentation.** A presentation package may use a public widget from another feature's presentation package, under the three conditions below. Read `${CLAUDE_PLUGIN_ROOT}/references/ffca/presentation.md`, section *Sharing a widget across features*.3132Data layers never reach across features for data, and no layer ever depends on another feature's data package.3334## Sharing data35361. **Loose coupling by id: the Summary pattern.** When a feature stores references to another feature's models, store ids only. The read model holds full objects (`Cart` with `List<Product>`); the stored summary holds ids (`CartSummary` with `List<String>`). The repository reads and writes summaries and only takes the full object when one is being created. Read `${CLAUDE_PLUGIN_ROOT}/references/ffca/domain.md`, section *Storing data*, and adapt the shapes in `${CLAUDE_PLUGIN_ROOT}/references/code_templates/domain_templates.md`.372. **Combine repositories with a Query.** To assemble a populated model from two features, add a `Query` in the consuming feature's domain that takes both repository interfaces. Read `${CLAUDE_PLUGIN_ROOT}/references/ffca/domain.md`, section *Reading the populated object*. Keep the Query in the consumer, never in the provider: the cart feature never learns how products are stored, and the product feature never learns that carts exist.383. **Normalize inside the repository, not a Query.** When an API returns nested objects belonging to another feature, split them inside the data repository, which may depend on another feature's domain interface. Read `${CLAUDE_PLUGIN_ROOT}/references/ffca/faq.md`, section *Dealing with nested objects*. The DTO-to-domain mapping is duplicated in the consuming data package on purpose: DRY is traded for bounded contexts here deliberately.3940Do not call these classes "use cases". They are Commands and Queries. See `${CLAUDE_PLUGIN_ROOT}/references/ffca/domain.md`, section *Business rules*.4142## Sharing a widget4344A widget that owns a `Cubit` is not a separate feature. It lives in its own feature's presentation package and is exported through a barrel. Two ways to get it onto another feature's screen, and the choice is about who places it.4546**Direct import behind a narrow barrel.** Three conditions, all from `${CLAUDE_PLUGIN_ROOT}/references/ffca/presentation.md`, section *Sharing a widget across features*:4748- The widget gets its own barrel. Consumers import `package:cart_presentation/cart_badge.dart`, never the primary `cart_presentation.dart` barrel.49- The barrel stays narrow. Its transitive imports must not reach the feature's modules or screens. Going through the primary barrel costs the consumer every screen and Cubit the feature owns, and it breaks deferred loading downstream.50- No cycles. If two features each need a widget from the other, extract the shared part downward into a third package instead of importing sideways.5152**A slot the app fills.** The consuming feature never learns the other feature exists: it declares a nullable `Widget` parameter and the app supplies it. Same inversion as navigation. Name the slot for its position (`trailingAction`), default it to nothing, and stop at two slots per module. Read `${CLAUDE_PLUGIN_ROOT}/references/ffca/presentation.md`, section *Or let the app place it*.5354**Choosing.** Use a slot when the widget is app chrome, such as a cart badge in an app bar, which belongs to the shell rather than to the screen around it. Use a direct import when the widget is genuinely part of what the consuming screen *is*. Read `${CLAUDE_PLUGIN_ROOT}/references/ffca/presentation.md`, section *Choosing between them*.5556## Where a shared widget should live5758When the same widget is wanted in more than one feature, work through `${CLAUDE_PLUGIN_ROOT}/references/ffca/presentation.md`, section *Where the widget should live*, in order:59601. **Does it need a repository or a domain type?** If not, it is a pure presentational component and belongs in `ui_kit`. This test is mechanical, not stylistic: shared packages depend on external packages only, so a widget that needs a repository cannot compile there.612. **If it does, split it.** The view taking a plain count goes in `ui_kit`; the Cubit plus that view stays in its feature behind its own barrel. A widget that genuinely gets reused across features is usually a presentational leaf with the stateful part left behind, which means the pressure was pointing at `ui_kit` all along.6263## When a Query is not enough: compose a feature6465If multi-domain logic grows its own models, screens, or lifecycle, create a feature for it. Read `${CLAUDE_PLUGIN_ROOT}/references/ffca/overview.md`, sections *Features* and *Presentation-only features*. A feature that composes several other domains into a screen without owning business logic is a presentation-only feature: a `{name}_presentation` package with no domain or data sibling, depending on the other features' domains.6667## Identity versus entity6869Auth and user profile are separate domains, not one. Read `${CLAUDE_PLUGIN_ROOT}/references/ffca/faq.md`, section *How do I handle auth and user profiles?* Keep `AuthUser` in `auth_domain` and `UserProfile` in `user_profile_domain`, and glue them with a Query in the consuming domain, so a new profile field never forces a change to auth.