{
  "schemaVersion": "1.0",
  "item": {
    "slug": "fosmvvm-fluent-datamodel-generator",
    "name": "FOSMVVM Fluent DataModel Generator",
    "source": "tencent",
    "type": "skill",
    "category": "开发工具",
    "sourceUrl": "https://clawhub.ai/foscomputerservices/fosmvvm-fluent-datamodel-generator",
    "canonicalUrl": "https://clawhub.ai/foscomputerservices/fosmvvm-fluent-datamodel-generator",
    "targetPlatform": "OpenClaw"
  },
  "install": {
    "downloadMode": "redirect",
    "downloadUrl": "/downloads/fosmvvm-fluent-datamodel-generator",
    "sourceDownloadUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=fosmvvm-fluent-datamodel-generator",
    "sourcePlatform": "tencent",
    "targetPlatform": "OpenClaw",
    "installMethod": "Manual import",
    "extraction": "Extract archive",
    "prerequisites": [
      "OpenClaw"
    ],
    "packageFormat": "ZIP package",
    "includedAssets": [
      "SKILL.md",
      "reference.md"
    ],
    "primaryDoc": "SKILL.md",
    "quickSetup": [
      "Download the package from Yavira.",
      "Extract the archive and review SKILL.md first.",
      "Import or place the package into your OpenClaw setup."
    ],
    "agentAssist": {
      "summary": "Hand the extracted package to your coding agent with a concrete install brief instead of figuring it out manually.",
      "steps": [
        "Download the package from Yavira.",
        "Extract it into a folder your agent can access.",
        "Paste one of the prompts below and point your agent at the extracted folder."
      ],
      "prompts": [
        {
          "label": "New install",
          "body": "I downloaded a skill package from Yavira. Read SKILL.md from the extracted folder and install it by following the included instructions. Tell me what you changed and call out any manual steps you could not complete."
        },
        {
          "label": "Upgrade existing",
          "body": "I downloaded an updated skill package from Yavira. Read SKILL.md from the extracted folder, compare it with my current installation, and upgrade it while preserving any custom configuration unless the package docs explicitly say otherwise. Summarize what changed and any follow-up checks I should run."
        }
      ]
    },
    "sourceHealth": {
      "source": "tencent",
      "status": "healthy",
      "reason": "direct_download_ok",
      "recommendedAction": "download",
      "checkedAt": "2026-04-30T16:55:25.780Z",
      "expiresAt": "2026-05-07T16:55:25.780Z",
      "httpStatus": 200,
      "finalUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=network",
      "contentType": "application/zip",
      "probeMethod": "head",
      "details": {
        "probeUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=network",
        "contentDisposition": "attachment; filename=\"network-1.0.0.zip\"",
        "redirectLocation": null,
        "bodySnippet": null
      },
      "scope": "source",
      "summary": "Source download looks usable.",
      "detail": "Yavira can redirect you to the upstream package for this source.",
      "primaryActionLabel": "Download for OpenClaw",
      "primaryActionHref": "/downloads/fosmvvm-fluent-datamodel-generator"
    },
    "validation": {
      "installChecklist": [
        "Use the Yavira download entry.",
        "Review SKILL.md after the package is downloaded.",
        "Confirm the extracted package contains the expected setup assets."
      ],
      "postInstallChecks": [
        "Confirm the extracted package includes the expected docs or setup files.",
        "Validate the skill or prompts are available in your target agent workspace.",
        "Capture any manual follow-up steps the agent could not complete."
      ]
    },
    "downloadPageUrl": "https://openagent3.xyz/downloads/fosmvvm-fluent-datamodel-generator",
    "agentPageUrl": "https://openagent3.xyz/skills/fosmvvm-fluent-datamodel-generator/agent",
    "manifestUrl": "https://openagent3.xyz/skills/fosmvvm-fluent-datamodel-generator/agent.json",
    "briefUrl": "https://openagent3.xyz/skills/fosmvvm-fluent-datamodel-generator/agent.md"
  },
  "agentAssist": {
    "summary": "Hand the extracted package to your coding agent with a concrete install brief instead of figuring it out manually.",
    "steps": [
      "Download the package from Yavira.",
      "Extract it into a folder your agent can access.",
      "Paste one of the prompts below and point your agent at the extracted folder."
    ],
    "prompts": [
      {
        "label": "New install",
        "body": "I downloaded a skill package from Yavira. Read SKILL.md from the extracted folder and install it by following the included instructions. Tell me what you changed and call out any manual steps you could not complete."
      },
      {
        "label": "Upgrade existing",
        "body": "I downloaded an updated skill package from Yavira. Read SKILL.md from the extracted folder, compare it with my current installation, and upgrade it while preserving any custom configuration unless the package docs explicitly say otherwise. Summarize what changed and any follow-up checks I should run."
      }
    ]
  },
  "documentation": {
    "source": "clawhub",
    "primaryDoc": "SKILL.md",
    "sections": [
      {
        "title": "FOSMVVM Fluent DataModel Generator",
        "body": "Generate Fluent DataModels for server-side persistence following FOSMVVM architecture.\n\nDependency: This skill uses fosmvvm-fields-generator for the Fields layer (protocol, messages, YAML). Run that skill first for form-backed models."
      },
      {
        "title": "Scope Guard",
        "body": "This skill is specifically for Fluent persistence layer (typically in Vapor server apps).\n\nSTOP and ask the user if:\n\nThe project doesn't use Fluent\nThe target is iOS-only with CoreData, SwiftData, or Realm\nThe user mentions a non-Fluent ORM or persistence layer\nYou're unsure whether Fluent is the persistence layer\n\nCheck for Fluent indicators:\n\nPackage.swift imports fluent, fluent-postgres-driver, fluent-sqlite-driver, etc.\nExisting models use @ID, @Field, @Parent, @Children, @Siblings property wrappers\nA Migrations/ directory exists with Fluent migration patterns\nImports include FluentKit or Fluent\n\nIf Fluent isn't present, inform the user: \"This skill generates Fluent DataModels for server-side persistence. Your project doesn't appear to use Fluent. How would you like to proceed?\""
      },
      {
        "title": "When to Use This Skill",
        "body": "User asks to create a new model/entity/table\nUser wants to add a database-backed type (Users, Ideas, Documents, etc.)\nUser mentions needing CRUD operations for a new concept\nCreating the persistence layer for a new entity"
      },
      {
        "title": "Architecture Context",
        "body": "In FOSMVVM, the Model is the center - the source of truth that reads and writes flow through.\n\nSee FOSMVVMArchitecture.md | OpenClaw reference for full context."
      },
      {
        "title": "DataModel in the Architecture",
        "body": "┌─────────────────────────────────────┐\n                    │         Fluent DataModel            │\n                    │    (implements Model + Fields)      │\n                    │                                     │\n                    │  • All fields (system + user)       │\n                    │  • Relationships (@Parent, etc.)    │\n                    │  • Timestamps, audit fields         │\n                    │  • Persistence logic                │\n                    └──────────────┬──────────────────────┘\n                                   │\n              ┌────────────────────┼────────────────────────┐\n              │                    │                        │\n              ▼                    ▼                        ▼\n    ┌─────────────────┐  ┌─────────────────┐    ┌─────────────────┐\n    │ ViewModelFactory│  │  CreateRequest  │    │  UpdateRequest  │\n    │   (projector)   │  │   RequestBody   │    │   RequestBody   │\n    │                 │  │                 │    │                 │\n    │ → ViewModel     │  │ → persists to   │    │ → updates       │\n    │   (projection)  │  │   DataModel     │    │   DataModel     │\n    └─────────────────┘  └─────────────────┘    └─────────────────┘"
      },
      {
        "title": "Fields vs DataModels",
        "body": "Fields protocol = Form input (user-editable subset)\n\nWhat users type into forms\nValidation, labels, placeholders\nNO relationships, NO system-assigned fields\n\nDataModel = Complete entity (Fluent implementation)\n\nAll fields including system-assigned (createdBy, timestamps)\nAll relationships (@Parent, @Siblings, @Children)\nFluent property wrappers, migrations, seeds\n\nNot all entities need Fields:\n\nSession: system auth, no user form → DataModel-only\nAudit records: system-generated → DataModel-only\nJunction tables: pure storage → DataModel-only"
      },
      {
        "title": "File Structure",
        "body": "Each form-backed model requires files across multiple targets:\n\n── fosmvvm-fields-generator ──────────────────────────────────\n{ViewModelsTarget}/                  (shared protocol layer)\n  FieldModels/\n    {Model}Fields.swift              ← Protocol + Enum + Validation\n    {Model}FieldsMessages.swift      ← Localization message struct\n\n{ResourcesPath}/                     (localization resources)\n  FieldModels/\n    {Model}FieldsMessages.yml        ← YAML localization strings\n\n── fosmvvm-fluent-datamodel-generator (this skill) ───────────\n{WebServerTarget}/                   (server implementation)\n  DataModels/\n    {Model}.swift                    ← Fluent model (implements protocol)\n  Migrations/\n    {Model}+Schema.swift             ← Table creation migration\n    {Model}+Seed.swift               ← Seed data migration\n\nTests/\n  {ViewModelsTarget}Tests/\n    FieldModels/\n      {Model}FieldsTests.swift       ← Unit tests\n\ndatabase.swift                       ← Register migrations"
      },
      {
        "title": "How to Use This Skill",
        "body": "Invocation:\n/fosmvvm-fluent-datamodel-generator\n\nPrerequisites:\n\nModel structure understood from conversation context\nFields protocol exists (if form-backed model) via fosmvvm-fields-generator\nRelationships and system-assigned fields identified\nFluent confirmed as the persistence layer\n\nWorkflow integration:\nThis skill is used for server-side persistence with Fluent. For form-backed models, run fosmvvm-fields-generator first to create the Fields protocol. The skill references conversation context automatically—no file paths or Q&A needed."
      },
      {
        "title": "Pattern Implementation",
        "body": "This skill references conversation context to determine DataModel structure:"
      },
      {
        "title": "Model Type Detection",
        "body": "From conversation context, the skill identifies:\n\nEntity purpose (user data, system records, audit logs, junction table)\nUser input involvement (form-backed vs system-generated)\nFields protocol requirement (if user edits this data)"
      },
      {
        "title": "Relationship Analysis",
        "body": "From requirements already in context:\n\nOne-to-many relationships (@Parent in DataModel, not in Fields)\nMany-to-many relationships (Junction table + @Siblings, NOT UUID arrays)\nRelationship naming (self-documenting names, not vague references)"
      },
      {
        "title": "Field Classification",
        "body": "Based on data source:\n\nUser-editable fields (from Fields protocol)\nSystem-assigned fields (createdBy, timestamps, status - DataModel only)\nComputed relationships (@Parent, @Children, @Siblings)"
      },
      {
        "title": "File Generation Order",
        "body": "If form-backed model (Fields protocol exists):\n\nFields layer already created via fosmvvm-fields-generator\nDataModel implementation referencing Fields\nSchema migration\nSeed data migration\nTests\nMigration registration\n\nIf system-only model (no Fields):\n\nDataModel struct\nSchema migration\nSeed data migration (if needed)\nTests\nMigration registration"
      },
      {
        "title": "Design Validation",
        "body": "Before generating, the skill validates:\n\nForm requirement - System-generated entities skip Fields\nRelationship patterns - Junction tables for many-to-many, @Parent for foreign keys\nNaming clarity - Relationships have self-documenting names\nField separation - User fields in protocol, system fields in DataModel only"
      },
      {
        "title": "Context Sources",
        "body": "Skill references information from:\n\nPrior conversation: Model requirements, relationships discussed\nFields protocol: If Claude has read Fields protocol into context or just created it\nDatabase schema: From codebase analysis of existing models\nMigration patterns: From existing migrations in project"
      },
      {
        "title": "File Templates",
        "body": "See reference.md for complete file templates with all patterns."
      },
      {
        "title": "Fluent DataModel",
        "body": "import FluentKit\nimport FOSFoundation\nimport FOSMVVM\nimport FOSMVVMVapor\nimport Foundation\n\nfinal class {Model}: DataModel, {Model}Fields, Hashable, @unchecked Sendable {\n    static let schema = \"{models}\"  // snake_case plural\n\n    @ID(key: .id) var id: ModelIdType?\n\n    // Fields from protocol\n    @Field(key: \"field_name\") var fieldName: FieldType\n\n    // Validation messages\n    let {model}ValidationMessages: {Model}FieldsMessages\n\n    // Timestamps\n    @Timestamp(key: \"created_at\", on: .create) var createdAt: Date?\n    @Timestamp(key: \"updated_at\", on: .update) var updatedAt: Date?\n\n    // CRITICAL: Initialize validationMessages FIRST\n    init() {\n        self.{model}ValidationMessages = .init()\n    }\n\n    init(id: ModelIdType? = nil, fieldName: FieldType) {\n        self.{model}ValidationMessages = .init()  // FIRST!\n        self.id = id\n        self.fieldName = fieldName\n    }\n}"
      },
      {
        "title": "Relationships (Associated Types Pattern)",
        "body": "PRINCIPLE: Existential types (any Protocol) are a code smell. Always ask \"Is there any other way?\" before using them.\n\nFor required relationships, use associated types in the protocol:\n\npublic protocol IdeaFields: ValidatableModel, Codable, Sendable {\n    associatedtype User: UserFields\n\n    var createdBy: User { get set }\n}\n\nIn the Fluent model, @Parent directly satisfies the protocol:\n\nfinal class Idea: DataModel, IdeaFields, Hashable, @unchecked Sendable {\n    @Parent(key: \"created_by\") var createdBy: User\n    // No computed property needed - @Parent satisfies the associated type directly\n}\n\nIn schema: .field(\"created_by\", .uuid, .required, .references(User.schema, \"id\", onDelete: .cascade))\n\nWhen to use each pattern:\n\nAssociated type (associatedtype User: UserFields): Required relationships\nOptional associated type: Not supported - use ModelIdType? for optional FKs\nPlain ModelIdType: Optional FKs, external system references"
      },
      {
        "title": "Migrations",
        "body": "Schema migration named: \"{Model.schema}-initial\"\nSeed migration named: \"{Model.schema}-seed\"\nSeed is environment-aware (debug, test, release)\nSeed is idempotent: guard count() == 0"
      },
      {
        "title": "Raw SQL in Migrations (PostgreSQL Features)",
        "body": "For PostgreSQL-specific features (tsvector, LTREE, etc.), use SQLKit:\n\nimport Fluent\nimport SQLKit  // Required for raw SQL\n\n// In prepare():\nguard let sql = database as? any SQLDatabase else { return }\n\nlet schema = Model.schema\ntry await sql.raw(SQLQueryString(\"ALTER TABLE \\(unsafeRaw: schema) ADD COLUMN search_vector tsvector\")).run()\n\nKey points:\n\nImport SQLKit (not just Fluent)\nCast database: database as? any SQLDatabase\nUse SQLQueryString with \\(unsafeRaw:) for identifiers\nThese columns are database-only (not in protocol or Fluent model)"
      },
      {
        "title": "Tests",
        "body": "Use @Suite annotation with descriptive name\nConform to LocalizableTestCase\nTest all form fields\nTest validation with @Test(arguments:)\nCreate private test struct implementing the Fields protocol\n\nTest structs with associated types:\n\nprivate struct TestIdea: IdeaFields {\n    typealias User = TestUser  // Satisfy the associated type\n\n    var id: ModelIdType?\n    var createdBy: TestUser    // Concrete type, not existential\n}\n\nprivate struct TestUser: UserFields {\n    var id: ModelIdType? = .init()\n    var firstName: String = \"Test\"\n    // ... other required fields with defaults\n}"
      },
      {
        "title": "Naming Conventions",
        "body": "ConceptConventionExampleModel classPascalCase singularUser, IdeaTable namesnake_case pluralusers, ideasField keyssnake_casecreated_at, user_idEnum casescamelCasesearchLanguage, inProgressEnum raw valuessnake_case\"search_language\", \"in_progress\"Protocol{Model}FieldsUserFields, IdeaFieldsMessages struct{Model}FieldsMessagesUserFieldsMessages"
      },
      {
        "title": "Common Field Types",
        "body": "Swift TypeFluent TypeDatabaseString.stringVARCHAR/TEXTInt.intINTEGERBool.boolBOOLEANDate.datetimeTIMESTAMPTZUUID.uuidUUID[UUID].array(of: .uuid)UUID[]Custom Enum.stringVARCHAR (stored as raw value)JSONB.jsonJSONB"
      },
      {
        "title": "See Also",
        "body": "FOSMVVMArchitecture.md - Full FOSMVVM architecture\nfosmvvm-fields-generator - For form validation (Fields protocols)\nfosmvvm-viewmodel-generator - For ViewModels that project from DataModels\nreference.md - Complete file templates"
      },
      {
        "title": "Version History",
        "body": "VersionDateChanges1.02025-12-23Initial skill based on SystemConfig pattern1.12025-12-23Added relationship patterns (@Parent), initialization order, imports list1.22025-12-23Associated types for relationships (not existentials), raw SQL patterns, test struct patterns1.32025-12-24Factored out Fields layer to fields-generator skill2.02025-12-26Renamed to fosmvvm-fluent-datamodel-generator, added Scope Guard, generalized from Kairos-specific to FOSMVVM patterns, added architecture context2.12026-01-24Update to context-aware approach (remove file-parsing/Q&A). Skill references conversation context instead of asking questions or accepting file paths."
      }
    ],
    "body": "FOSMVVM Fluent DataModel Generator\n\nGenerate Fluent DataModels for server-side persistence following FOSMVVM architecture.\n\nDependency: This skill uses fosmvvm-fields-generator for the Fields layer (protocol, messages, YAML). Run that skill first for form-backed models.\n\nScope Guard\n\nThis skill is specifically for Fluent persistence layer (typically in Vapor server apps).\n\nSTOP and ask the user if:\n\nThe project doesn't use Fluent\nThe target is iOS-only with CoreData, SwiftData, or Realm\nThe user mentions a non-Fluent ORM or persistence layer\nYou're unsure whether Fluent is the persistence layer\n\nCheck for Fluent indicators:\n\nPackage.swift imports fluent, fluent-postgres-driver, fluent-sqlite-driver, etc.\nExisting models use @ID, @Field, @Parent, @Children, @Siblings property wrappers\nA Migrations/ directory exists with Fluent migration patterns\nImports include FluentKit or Fluent\n\nIf Fluent isn't present, inform the user: \"This skill generates Fluent DataModels for server-side persistence. Your project doesn't appear to use Fluent. How would you like to proceed?\"\n\nWhen to Use This Skill\nUser asks to create a new model/entity/table\nUser wants to add a database-backed type (Users, Ideas, Documents, etc.)\nUser mentions needing CRUD operations for a new concept\nCreating the persistence layer for a new entity\nArchitecture Context\n\nIn FOSMVVM, the Model is the center - the source of truth that reads and writes flow through.\n\nSee FOSMVVMArchitecture.md | OpenClaw reference for full context.\n\nDataModel in the Architecture\n                    ┌─────────────────────────────────────┐\n                    │         Fluent DataModel            │\n                    │    (implements Model + Fields)      │\n                    │                                     │\n                    │  • All fields (system + user)       │\n                    │  • Relationships (@Parent, etc.)    │\n                    │  • Timestamps, audit fields         │\n                    │  • Persistence logic                │\n                    └──────────────┬──────────────────────┘\n                                   │\n              ┌────────────────────┼────────────────────────┐\n              │                    │                        │\n              ▼                    ▼                        ▼\n    ┌─────────────────┐  ┌─────────────────┐    ┌─────────────────┐\n    │ ViewModelFactory│  │  CreateRequest  │    │  UpdateRequest  │\n    │   (projector)   │  │   RequestBody   │    │   RequestBody   │\n    │                 │  │                 │    │                 │\n    │ → ViewModel     │  │ → persists to   │    │ → updates       │\n    │   (projection)  │  │   DataModel     │    │   DataModel     │\n    └─────────────────┘  └─────────────────┘    └─────────────────┘\n\nFields vs DataModels\n\nFields protocol = Form input (user-editable subset)\n\nWhat users type into forms\nValidation, labels, placeholders\nNO relationships, NO system-assigned fields\n\nDataModel = Complete entity (Fluent implementation)\n\nAll fields including system-assigned (createdBy, timestamps)\nAll relationships (@Parent, @Siblings, @Children)\nFluent property wrappers, migrations, seeds\n\nNot all entities need Fields:\n\nSession: system auth, no user form → DataModel-only\nAudit records: system-generated → DataModel-only\nJunction tables: pure storage → DataModel-only\nFile Structure\n\nEach form-backed model requires files across multiple targets:\n\n── fosmvvm-fields-generator ──────────────────────────────────\n{ViewModelsTarget}/                  (shared protocol layer)\n  FieldModels/\n    {Model}Fields.swift              ← Protocol + Enum + Validation\n    {Model}FieldsMessages.swift      ← Localization message struct\n\n{ResourcesPath}/                     (localization resources)\n  FieldModels/\n    {Model}FieldsMessages.yml        ← YAML localization strings\n\n── fosmvvm-fluent-datamodel-generator (this skill) ───────────\n{WebServerTarget}/                   (server implementation)\n  DataModels/\n    {Model}.swift                    ← Fluent model (implements protocol)\n  Migrations/\n    {Model}+Schema.swift             ← Table creation migration\n    {Model}+Seed.swift               ← Seed data migration\n\nTests/\n  {ViewModelsTarget}Tests/\n    FieldModels/\n      {Model}FieldsTests.swift       ← Unit tests\n\ndatabase.swift                       ← Register migrations\n\nHow to Use This Skill\n\nInvocation: /fosmvvm-fluent-datamodel-generator\n\nPrerequisites:\n\nModel structure understood from conversation context\nFields protocol exists (if form-backed model) via fosmvvm-fields-generator\nRelationships and system-assigned fields identified\nFluent confirmed as the persistence layer\n\nWorkflow integration: This skill is used for server-side persistence with Fluent. For form-backed models, run fosmvvm-fields-generator first to create the Fields protocol. The skill references conversation context automatically—no file paths or Q&A needed.\n\nPattern Implementation\n\nThis skill references conversation context to determine DataModel structure:\n\nModel Type Detection\n\nFrom conversation context, the skill identifies:\n\nEntity purpose (user data, system records, audit logs, junction table)\nUser input involvement (form-backed vs system-generated)\nFields protocol requirement (if user edits this data)\nRelationship Analysis\n\nFrom requirements already in context:\n\nOne-to-many relationships (@Parent in DataModel, not in Fields)\nMany-to-many relationships (Junction table + @Siblings, NOT UUID arrays)\nRelationship naming (self-documenting names, not vague references)\nField Classification\n\nBased on data source:\n\nUser-editable fields (from Fields protocol)\nSystem-assigned fields (createdBy, timestamps, status - DataModel only)\nComputed relationships (@Parent, @Children, @Siblings)\nFile Generation Order\n\nIf form-backed model (Fields protocol exists):\n\nFields layer already created via fosmvvm-fields-generator\nDataModel implementation referencing Fields\nSchema migration\nSeed data migration\nTests\nMigration registration\n\nIf system-only model (no Fields):\n\nDataModel struct\nSchema migration\nSeed data migration (if needed)\nTests\nMigration registration\nDesign Validation\n\nBefore generating, the skill validates:\n\nForm requirement - System-generated entities skip Fields\nRelationship patterns - Junction tables for many-to-many, @Parent for foreign keys\nNaming clarity - Relationships have self-documenting names\nField separation - User fields in protocol, system fields in DataModel only\nContext Sources\n\nSkill references information from:\n\nPrior conversation: Model requirements, relationships discussed\nFields protocol: If Claude has read Fields protocol into context or just created it\nDatabase schema: From codebase analysis of existing models\nMigration patterns: From existing migrations in project\nFile Templates\n\nSee reference.md for complete file templates with all patterns.\n\nKey Patterns\nFluent DataModel\nimport FluentKit\nimport FOSFoundation\nimport FOSMVVM\nimport FOSMVVMVapor\nimport Foundation\n\nfinal class {Model}: DataModel, {Model}Fields, Hashable, @unchecked Sendable {\n    static let schema = \"{models}\"  // snake_case plural\n\n    @ID(key: .id) var id: ModelIdType?\n\n    // Fields from protocol\n    @Field(key: \"field_name\") var fieldName: FieldType\n\n    // Validation messages\n    let {model}ValidationMessages: {Model}FieldsMessages\n\n    // Timestamps\n    @Timestamp(key: \"created_at\", on: .create) var createdAt: Date?\n    @Timestamp(key: \"updated_at\", on: .update) var updatedAt: Date?\n\n    // CRITICAL: Initialize validationMessages FIRST\n    init() {\n        self.{model}ValidationMessages = .init()\n    }\n\n    init(id: ModelIdType? = nil, fieldName: FieldType) {\n        self.{model}ValidationMessages = .init()  // FIRST!\n        self.id = id\n        self.fieldName = fieldName\n    }\n}\n\nRelationships (Associated Types Pattern)\n\nPRINCIPLE: Existential types (any Protocol) are a code smell. Always ask \"Is there any other way?\" before using them.\n\nFor required relationships, use associated types in the protocol:\n\npublic protocol IdeaFields: ValidatableModel, Codable, Sendable {\n    associatedtype User: UserFields\n\n    var createdBy: User { get set }\n}\n\n\nIn the Fluent model, @Parent directly satisfies the protocol:\n\nfinal class Idea: DataModel, IdeaFields, Hashable, @unchecked Sendable {\n    @Parent(key: \"created_by\") var createdBy: User\n    // No computed property needed - @Parent satisfies the associated type directly\n}\n\n\nIn schema: .field(\"created_by\", .uuid, .required, .references(User.schema, \"id\", onDelete: .cascade))\n\nWhen to use each pattern:\n\nAssociated type (associatedtype User: UserFields): Required relationships\nOptional associated type: Not supported - use ModelIdType? for optional FKs\nPlain ModelIdType: Optional FKs, external system references\nMigrations\nSchema migration named: \"{Model.schema}-initial\"\nSeed migration named: \"{Model.schema}-seed\"\nSeed is environment-aware (debug, test, release)\nSeed is idempotent: guard count() == 0\nRaw SQL in Migrations (PostgreSQL Features)\n\nFor PostgreSQL-specific features (tsvector, LTREE, etc.), use SQLKit:\n\nimport Fluent\nimport SQLKit  // Required for raw SQL\n\n// In prepare():\nguard let sql = database as? any SQLDatabase else { return }\n\nlet schema = Model.schema\ntry await sql.raw(SQLQueryString(\"ALTER TABLE \\(unsafeRaw: schema) ADD COLUMN search_vector tsvector\")).run()\n\n\nKey points:\n\nImport SQLKit (not just Fluent)\nCast database: database as? any SQLDatabase\nUse SQLQueryString with \\(unsafeRaw:) for identifiers\nThese columns are database-only (not in protocol or Fluent model)\nTests\nUse @Suite annotation with descriptive name\nConform to LocalizableTestCase\nTest all form fields\nTest validation with @Test(arguments:)\nCreate private test struct implementing the Fields protocol\n\nTest structs with associated types:\n\nprivate struct TestIdea: IdeaFields {\n    typealias User = TestUser  // Satisfy the associated type\n\n    var id: ModelIdType?\n    var createdBy: TestUser    // Concrete type, not existential\n}\n\nprivate struct TestUser: UserFields {\n    var id: ModelIdType? = .init()\n    var firstName: String = \"Test\"\n    // ... other required fields with defaults\n}\n\nNaming Conventions\nConcept\tConvention\tExample\nModel class\tPascalCase singular\tUser, Idea\nTable name\tsnake_case plural\tusers, ideas\nField keys\tsnake_case\tcreated_at, user_id\nEnum cases\tcamelCase\tsearchLanguage, inProgress\nEnum raw values\tsnake_case\t\"search_language\", \"in_progress\"\nProtocol\t{Model}Fields\tUserFields, IdeaFields\nMessages struct\t{Model}FieldsMessages\tUserFieldsMessages\nCommon Field Types\nSwift Type\tFluent Type\tDatabase\nString\t.string\tVARCHAR/TEXT\nInt\t.int\tINTEGER\nBool\t.bool\tBOOLEAN\nDate\t.datetime\tTIMESTAMPTZ\nUUID\t.uuid\tUUID\n[UUID]\t.array(of: .uuid)\tUUID[]\nCustom Enum\t.string\tVARCHAR (stored as raw value)\nJSONB\t.json\tJSONB\nSee Also\nFOSMVVMArchitecture.md - Full FOSMVVM architecture\nfosmvvm-fields-generator - For form validation (Fields protocols)\nfosmvvm-viewmodel-generator - For ViewModels that project from DataModels\nreference.md - Complete file templates\nVersion History\nVersion\tDate\tChanges\n1.0\t2025-12-23\tInitial skill based on SystemConfig pattern\n1.1\t2025-12-23\tAdded relationship patterns (@Parent), initialization order, imports list\n1.2\t2025-12-23\tAssociated types for relationships (not existentials), raw SQL patterns, test struct patterns\n1.3\t2025-12-24\tFactored out Fields layer to fields-generator skill\n2.0\t2025-12-26\tRenamed to fosmvvm-fluent-datamodel-generator, added Scope Guard, generalized from Kairos-specific to FOSMVVM patterns, added architecture context\n2.1\t2026-01-24\tUpdate to context-aware approach (remove file-parsing/Q&A). Skill references conversation context instead of asking questions or accepting file paths."
  },
  "trust": {
    "sourceLabel": "tencent",
    "provenanceUrl": "https://clawhub.ai/foscomputerservices/fosmvvm-fluent-datamodel-generator",
    "publisherUrl": "https://clawhub.ai/foscomputerservices/fosmvvm-fluent-datamodel-generator",
    "owner": "foscomputerservices",
    "version": "2.0.6",
    "license": null,
    "verificationStatus": "Indexed source record"
  },
  "links": {
    "detailUrl": "https://openagent3.xyz/skills/fosmvvm-fluent-datamodel-generator",
    "downloadUrl": "https://openagent3.xyz/downloads/fosmvvm-fluent-datamodel-generator",
    "agentUrl": "https://openagent3.xyz/skills/fosmvvm-fluent-datamodel-generator/agent",
    "manifestUrl": "https://openagent3.xyz/skills/fosmvvm-fluent-datamodel-generator/agent.json",
    "briefUrl": "https://openagent3.xyz/skills/fosmvvm-fluent-datamodel-generator/agent.md"
  }
}