# Sf Schema

> |

- **Type:** Skill
- **Install:** `agentstack add skill-clientell-ai-salesforce-skills-sf-schema`
- **Verified:** Yes — security-reviewed for prompt injection and unsafe behavior
- **Seller:** [Clientell-Ai](https://agentstack.voostack.com/s/clientell-ai)
- **Installs:** 0
- **Category:** [Agent Skills](https://agentstack.voostack.com/c/agent-skills)
- **Latest version:** 0.1.0
- **License:** Apache-2.0
- **Upstream author:** [Clientell-Ai](https://github.com/Clientell-Ai)
- **Source:** https://github.com/Clientell-Ai/salesforce-skills/tree/main/skills/sf-schema

## Install

```sh
agentstack add skill-clientell-ai-salesforce-skills-sf-schema
```

Requires the [AgentStack CLI](https://agentstack.voostack.com/docs/cli). Works with Claude Code, Cursor, and any MCP-compatible agent.

## About

# Schema Design & Permission Management

You are a Salesforce schema and metadata specialist. Generate valid SFDX source format metadata.

## Custom Object
```xml

    Invoice
    Invoices
    
        Invoice Number
        AutoNumber
        INV-{000000}
    
    Deployed
    Private
    true
    true
    true

```

## Custom Fields
```xml

    Amount__c
    Amount
    Currency
    18
    2
    true

```

### Common Field Types
```xml

Text
255

LongTextArea
32768
5

Picklist

    true
    
        false
        ActivetrueActive
        InactivefalseInactive
    

Lookup
Account
Invoices
Invoices

MasterDetail
Account
Invoices
Invoices
false
false

Checkbox
false

Date

DateTime

Number
18
0

Text
Account__r.Name &amp; ' - ' &amp; TEXT(Amount__c)
```

## Validation Rules
```xml

    Amount_Must_Be_Positive
    true
    Amount__c &lt;= 0
    Amount__c
    Amount must be greater than zero.

```

## Permission Sets
```xml

    Invoice Manager
    false
    
        Invoice__c
        true
        false
        true
        true
        false
        true
    
    
        Invoice__c.Amount__c
        true
        true
    
    
        Invoice__c.Status__c
        true
        true
    

```

## Custom Permissions (for Flow Bypass)
```xml

    Bypass Automation
    false

```

### Additional Field Types

**Formula Field:**
```xml

    FullName__c
    Full Name
    Text
    FirstName__c &amp; ' ' &amp; LastName__c
    BlankAsZero

```

**Rollup Summary Field** (master-detail only):
```xml

    Total_Amount__c
    Total Amount
    Summary
    LineItem__c.Amount__c
    sum
    LineItem__c.Order__c

```

**Geolocation Field:**
```xml
Location
true
6
```

**Global Value Set (Reusable Picklist):**
```xml

    Industries
    false
    TechnologyfalseTechnology
    HealthcarefalseHealthcare

```

### Relationship Types
| Type | Delete Behavior | Rollup Summary | Reparenting | Max per Object |
|------|----------------|----------------|-------------|----------------|
| Master-Detail | Cascade delete | Yes | Configurable | 2 |
| Lookup | Block/Clear/Restrict | No | N/A | 40 (25 std) |
| External Lookup | N/A | No | N/A | - |
| Hierarchical | N/A | No | N/A | 1 (User only) |
| Junction (M2M) | Two master-details | On both parents | - | - |

### Record Types
```xml

    Enterprise
    Enterprise
    true
    Enterprise Sales Process
    For enterprise accounts

```

### Custom Metadata Types vs Custom Settings
| Feature | Custom Metadata Types | Custom Settings (Hierarchy) |
|---------|----------------------|---------------------------|
| Deployable | Yes (metadata) | No (data) |
| SOQL required | Yes (or getInstance) | No (getOrgDefaults) |
| User/Profile override | No | Yes |
| Counts against SOQL limit | Yes | No |
| Use for | Org config, mappings | User preferences |

### Permission Set Groups
```xml

    Sales Team
    
        Account_Manager
        Opportunity_Editor
        Report_Viewer
    

```

## SFDX Source Directory Structure
```
force-app/main/default/
├── objects/
│   └── Invoice__c/
│       ├── Invoice__c.object-meta.xml
│       ├── fields/
│       │   ├── Amount__c.field-meta.xml
│       │   └── Status__c.field-meta.xml
│       ├── validationRules/
│       │   └── Amount_Must_Be_Positive.validationRule-meta.xml
│       └── listViews/
│           └── All.listView-meta.xml
├── permissionsets/
│   └── Invoice_Manager.permissionset-meta.xml
├── customPermissions/
│   └── Bypass_Automation.customPermission-meta.xml
└── layouts/
    └── Invoice__c-Invoice Layout.layout-meta.xml
```

## Gotchas
- Max **40 custom relationships** per object (25 for standard objects)
- Formula fields **cannot reference** LongTextArea, RichTextArea, MultiSelectPicklist, or Encrypted fields
- Rollup Summary fields work **only on Master-Detail** relationships — not Lookups
- Global Value Sets **cannot be converted back** to local picklists once shared
- Encrypted Text fields are **not searchable or sortable**
- Record type-dependent picklists require **explicit value mapping** per record type
- Permission Set Groups **recalculate asynchronously** — changes may take minutes to apply
- Custom Metadata Type records **cannot be created/updated via DML in production** — deploy only
- Profiles are **notoriously merge-conflict-prone** — prefer Permission Sets for everything

## References
- [Schema Reference](references/schema-reference.md) — formula fields, rollup summaries, geolocation, Global Value Sets, record types, page layouts, FlexiPages, custom metadata, platform events, Big Objects, quick actions, custom labels

## Workflow
1. Understand object/field requirements
2. Generate SFDX source format XML files
3. Generate permission set for new objects/fields
4. Deploy schema first, then code that references it
5. Verify with: `sf org list metadata -m CustomObject --target-org myOrg`

## Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

- **Author:** [Clientell-Ai](https://github.com/Clientell-Ai)
- **Source:** [Clientell-Ai/salesforce-skills](https://github.com/Clientell-Ai/salesforce-skills)
- **License:** Apache-2.0

Install and usage instructions live in the source repository linked above.

## Pricing

- **Free** — Free

## Security capabilities

Automated source analysis of v0.1.0 — what this tool can access:

- **Network access:** no
- **Filesystem access:** no
- **Shell / process execution:** no
- **Environment & secrets:** no
- **Dynamic code execution:** no

*"Yes" means the capability is present in the source — more access means more to trust, not that it is unsafe.*


## Versions

- **0.1.0** — security scan: passed — Imported from the upstream source.

## Links

- Listing page: https://agentstack.voostack.com/l/skill-clientell-ai-salesforce-skills-sf-schema
- Seller: https://agentstack.voostack.com/s/clientell-ai
- Browse the marketplace: https://agentstack.voostack.com/browse

---
Listed on AgentStack — the marketplace for AI agent skills and MCP servers. Every listing is security-reviewed. Creators keep 70%.
