$npx -y skills add freestylefly/canghe-skills --skill obsidian-basesCreate and edit Obsidian Bases (.base files) with views, filters, formulas, and summaries. Use when working with .base files, creating database-like views of notes, or when the user mentions Bases, table views, card views, filters, or formulas in Obsidian.
| 1 | # Obsidian Bases Skill |
| 2 | |
| 3 | This skill enables skills-compatible agents to create and edit valid Obsidian Bases (`.base` files) including views, filters, formulas, and all related configurations. |
| 4 | |
| 5 | ## Overview |
| 6 | |
| 7 | Obsidian Bases are YAML-based files that define dynamic views of notes in an Obsidian vault. A Base file can contain multiple views, global filters, formulas, property configurations, and custom summaries. |
| 8 | |
| 9 | ## File Format |
| 10 | |
| 11 | Base files use the `.base` extension and contain valid YAML. They can also be embedded in Markdown code blocks. |
| 12 | |
| 13 | ## Complete Schema |
| 14 | |
| 15 | ```yaml |
| 16 | # Global filters apply to ALL views in the base |
| 17 | filters: |
| 18 | # Can be a single filter string |
| 19 | # OR a recursive filter object with and/or/not |
| 20 | and: [] |
| 21 | or: [] |
| 22 | not: [] |
| 23 | |
| 24 | # Define formula properties that can be used across all views |
| 25 | formulas: |
| 26 | formula_name: 'expression' |
| 27 | |
| 28 | # Configure display names and settings for properties |
| 29 | properties: |
| 30 | property_name: |
| 31 | displayName: "Display Name" |
| 32 | formula.formula_name: |
| 33 | displayName: "Formula Display Name" |
| 34 | file.ext: |
| 35 | displayName: "Extension" |
| 36 | |
| 37 | # Define custom summary formulas |
| 38 | summaries: |
| 39 | custom_summary_name: 'values.mean().round(3)' |
| 40 | |
| 41 | # Define one or more views |
| 42 | views: |
| 43 | - type: table | cards | list | map |
| 44 | name: "View Name" |
| 45 | limit: 10 # Optional: limit results |
| 46 | groupBy: # Optional: group results |
| 47 | property: property_name |
| 48 | direction: ASC | DESC |
| 49 | filters: # View-specific filters |
| 50 | and: [] |
| 51 | order: # Properties to display in order |
| 52 | - file.name |
| 53 | - property_name |
| 54 | - formula.formula_name |
| 55 | summaries: # Map properties to summary formulas |
| 56 | property_name: Average |
| 57 | ``` |
| 58 | |
| 59 | ## Filter Syntax |
| 60 | |
| 61 | Filters narrow down results. They can be applied globally or per-view. |
| 62 | |
| 63 | ### Filter Structure |
| 64 | |
| 65 | ```yaml |
| 66 | # Single filter |
| 67 | filters: 'status == "done"' |
| 68 | |
| 69 | # AND - all conditions must be true |
| 70 | filters: |
| 71 | and: |
| 72 | - 'status == "done"' |
| 73 | - 'priority > 3' |
| 74 | |
| 75 | # OR - any condition can be true |
| 76 | filters: |
| 77 | or: |
| 78 | - 'file.hasTag("book")' |
| 79 | - 'file.hasTag("article")' |
| 80 | |
| 81 | # NOT - exclude matching items |
| 82 | filters: |
| 83 | not: |
| 84 | - 'file.hasTag("archived")' |
| 85 | |
| 86 | # Nested filters |
| 87 | filters: |
| 88 | or: |
| 89 | - file.hasTag("tag") |
| 90 | - and: |
| 91 | - file.hasTag("book") |
| 92 | - file.hasLink("Textbook") |
| 93 | - not: |
| 94 | - file.hasTag("book") |
| 95 | - file.inFolder("Required Reading") |
| 96 | ``` |
| 97 | |
| 98 | ### Filter Operators |
| 99 | |
| 100 | | Operator | Description | |
| 101 | |----------|-------------| |
| 102 | | `==` | equals | |
| 103 | | `!=` | not equal | |
| 104 | | `>` | greater than | |
| 105 | | `<` | less than | |
| 106 | | `>=` | greater than or equal | |
| 107 | | `<=` | less than or equal | |
| 108 | | `&&` | logical and | |
| 109 | | `\|\|` | logical or | |
| 110 | | <code>!</code> | logical not | |
| 111 | |
| 112 | ## Properties |
| 113 | |
| 114 | ### Three Types of Properties |
| 115 | |
| 116 | 1. **Note properties** - From frontmatter: `note.author` or just `author` |
| 117 | 2. **File properties** - File metadata: `file.name`, `file.mtime`, etc. |
| 118 | 3. **Formula properties** - Computed values: `formula.my_formula` |
| 119 | |
| 120 | ### File Properties Reference |
| 121 | |
| 122 | | Property | Type | Description | |
| 123 | |----------|------|-------------| |
| 124 | | `file.name` | String | File name | |
| 125 | | `file.basename` | String | File name without extension | |
| 126 | | `file.path` | String | Full path to file | |
| 127 | | `file.folder` | String | Parent folder path | |
| 128 | | `file.ext` | String | File extension | |
| 129 | | `file.size` | Number | File size in bytes | |
| 130 | | `file.ctime` | Date | Created time | |
| 131 | | `file.mtime` | Date | Modified time | |
| 132 | | `file.tags` | List | All tags in file | |
| 133 | | `file.links` | List | Internal links in file | |
| 134 | | `file.backlinks` | List | Files linking to this file | |
| 135 | | `file.embeds` | List | Embeds in the note | |
| 136 | | `file.properties` | Object | All frontmatter properties | |
| 137 | |
| 138 | ### The `this` Keyword |
| 139 | |
| 140 | - In main content area: refers to the base file itself |
| 141 | - When embedded: refers to the embedding file |
| 142 | - In sidebar: refers to the active file in main content |
| 143 | |
| 144 | ## Formula Syntax |
| 145 | |
| 146 | Formulas compute values from properties. Defined in the `formulas` section. |
| 147 | |
| 148 | ```yaml |
| 149 | formulas: |
| 150 | # Simple arithmetic |
| 151 | total: "price * quantity" |
| 152 | |
| 153 | # Conditional logic |
| 154 | status_icon: 'if(done, "✅", "⏳")' |
| 155 | |
| 156 | # String formatting |
| 157 | formatted_price: 'if(price, price.toFixed(2) + " dollars")' |
| 158 | |
| 159 | # Date formatting |
| 160 | created: 'file.ctime.format("YYYY-MM-DD")' |
| 161 | |
| 162 | # Complex expressions |
| 163 | days_old: '((now() - file.ctime) / 86400000).round(0)' |
| 164 | ``` |
| 165 | |
| 166 | ## Functions Reference |
| 167 | |
| 168 | ### Global Functions |
| 169 | |
| 170 | | Function | Signature | Description | |
| 171 | |----------|-----------|-------------| |
| 172 | | `date()` | `date(string): date` | Parse string to date. Format: `YYYY-MM-DD HH:mm:ss` | |
| 173 | | `duration()` | `duration(string): duration` | Parse duration string | |
| 174 | | `now()` | `now(): date` | Current date and time | |
| 175 | | `today()` | `today(): date` | |