Organize Library
Purpose
Fully organize a SharePoint document library by:
- Classifying files by content type and extracting metadata
- Applying brand-consistent column and view formatting
- Creating filtered views per content type
- Setting folder colors
- Creating notification rules for overdue items
Orchestrates the file-classifier skill for classification and reads SHAREPOINT.md for brand guidelines.
Design Principle — Incremental Visual Feedback
Give the user visible progress at each step rather than a long silent period:
- After Step 2: Colored folders appear
- After Step 3b: Color-coded classification pills appear
- After Step 3c: Grouped default view with styled headers
- After Step 4: Metadata columns formatted with pills, data bars, overdue highlights
- After Step 5: Per-content-type views appear in the view picker
- After Step 6: Notification rules active — library is fully operational
Always report progress after each sub-step.
Brand Colors
Always read SHAREPOINT.md before applying any formatting. Resolve all color role names to hex values at runtime. For semi-transparent pill backgrounds, convert hex to rgba() at the specified opacity. Always use 4 parameters — never rgb().
Disambiguation: SHAREPOINT.md defines two Blue-Gray values. "Blue-Gray (Status)" = On Hold (#94A3B8). "Blue-Gray (Muted)" = muted text (#6B7280). Never swap them.
Fallback palette (no SHAREPOINT.md)
If SHAREPOINT.md is not present in the workspace, or if the read fails, do not abort. Tell the user SHAREPOINT.md was not found, that a neutral fallback palette is being used, and that they can re-run after adding a brand file for branded results. Then continue with these hex values mapped to the same role names used elsewhere in this skill:
Use the fallback values exactly as if they had come from SHAREPOINT.md. All other rules in this skill apply unchanged.
Content Type Column Pattern
Each content type gets exactly 5 metadata columns:
Column Definitions
Contracts
Invoices
Purchase Orders
VendorSupplierName is shared across Invoices and Purchase Orders — create once, reuse.
Workflow
Step 1 — Assess the Library
- Call
get_list_schema to get columns, views, item count, and settings.
- Call
list_items (itemType="folders") and (itemType="files") to inventory the library.
- Present summary: file count, folder count, existing columns, existing views.
- Confirm with the user before proceeding.
Step 2 — Color Folders
- Apply Default Folder Color from SHAREPOINT.md to all folders using
set_folder_color. Batch in a single call.
- If content-type-named folders exist, assign: Contracts → DARK_PURPLE, Invoices → DARK_BLUE, Purchase Orders → DARK_GREEN.
- Report: "Folders are now color-coded."
3a — Run file-classifier
- Load with
load_skill(skillName="file-classifier").
- Follow the full file-classifier workflow: create FileClassification column, read files, classify, create metadata columns, extract values, save with
update_list_items_v2.
Apply pill formatting to FileClassification using brand colors from SHAREPOINT.md.
Pill structure (use everywhere pills appear):
- Root div:
display: flex; align-items: center; height: 100% — no background.
- Inner span:
display: inline-block; border-radius: 16px; padding: 4px 12px; font-size: 12px; font-weight: 600; white-space: nowrap — carries background and text color.
Color assignment:
Use apply_column_formatting with a conditional JSON formatter checking @currentField against each content type.
Report: Classification results — file counts per type, any unclassified files. User should now see color-coded pills.
- Update "All Documents" view with
create_or_update_list:
- viewFields: FileLeafRef, FileClassification, Modified, Editor only. Do not add metadata columns to the default view.
- Group by FileClassification (Collapse="FALSE"), sort by Modified descending.
- Apply view formatting with
apply_view_formatting (row-formatting schema):
- Group headers: Deep Navy text on Light Blue background, bold, shows
@group.fieldData.displayValue + item count.
- Rows: clean white, no alternating colors.
- Schema:
https://developer.microsoft.com/json-schemas/sp/v2/row-formatting.schema.json
Report: "Default view is now grouped by classification with styled headers."
Confirm with the user before proceeding to metadata formatting.
Metadata was written in Step 3a. This step applies visual formatting only. Check schema before formatting — only format columns that exist.
Date Columns (ExpirationEndDate, PaymentDueDate, RequiredDeliveryDate)
- Root div with icon span + text span.
- Not overdue (
@currentField > @now): CalendarDay icon ("Event") in Blue-Gray (Status) + @currentField.displayValue in normal text.
- Overdue (
@currentField <= @now): Pill — Deep Purple background, white text and icon.
- Warning icon + relative display string:
"{N} days ago ({date})" where:
- N =
toString(floor((toNumber(@now) - toNumber(@currentField)) / 86400000))
- date =
@currentField.displayValue
- Full expression:
"=" + toString(floor((toNumber(@now) - toNumber(@currentField)) / 86400000)) + " days ago (" + @currentField.displayValue + ")"
- 86400000 = milliseconds per day (1000 × 60 × 60 × 24);
floor() drops the fractional day so the count is always whole numbers.
- Example output:
⚠ 79 days ago (January 31, 2026)
Number Columns (ContractValue, TotalAmountDue, TotalOrderValue)
- Data bar formatting using Primary (Contoso Blue).
sp-field-dataBars class with width expression based on field value.
Status Columns (ContractStatus, PaymentStatus, POStatus)
- Inner-element pill structure (same structure as FileClassification pills above).
- Icon span (
iconName) + text span inside the inner pill span.
Status color mapping:
Pill background: status color at 15% opacity (40% for Pending). Text: full status color hex. Exception: Pending uses a darker shade of #BDD7EE for text contrast.
Report: "Formatted X date columns with overdue highlighting, X status columns with icon pills, X number columns with data bars."
Step 5 — Create Per-Content-Type Views
For each content type detected, create one view with create_or_update_list:
- View name: content type name ("Contracts", "Invoices", "Purchase Orders").
- viewFields: FileLeafRef, FileClassification, the 5 metadata columns for that type, Modified, Editor.
- CAML Where filter:
<Where><Eq><FieldRef Name='FileClassification'/><Value Type='Choice'>[ContentTypeName]</Value></Eq></Where>
- Sort by the Critical Date column (col 3) ascending, then Modified descending.
isNewView: true.
Batch views in groups of 5 or fewer per call.
Report: "Created X views — one per content type. Switch between them in the view picker."