๐ Shared Instructions: shared-instructions.md - Cross-cutting concerns.
References:
Two paths: existing lists (skip to Step 6) or new lists (full workflow).
Check for memory-bank.md per shared-instructions.md.
Ask the user:
If lists already exist: Skip to Step 6.
If creating new lists:
EnterPlanMode, present the list designs with columns and typesExitPlanModeSee api-authentication-reference.md for full details.
az account show # Verify Azure CLI logged in
$api = Initialize-SharePointGraphApi -SiteUrl "https://<tenant>.sharepoint.com/sites/<site-name>"
$headers = $api.Headers
$siteId = $api.SiteId
Requires Sites.Manage.All permission.
Always query existing lists first before creating:
$existingLists = Invoke-RestMethod -Uri "https://graph.microsoft.com/v1.0/sites/$siteId/lists?`$select=id,displayName,description,list&`$filter=list/hidden eq false" -Headers $headers
See list-management-reference.md for Find-SimilarLists, Compare-ListSchemas, and Get-ListSchema functions.
Present findings to user with AskUserQuestion:
Get explicit confirmation before creating. Use safe functions from list-management-reference.md:
New-SharePointListIfNotExistsAdd-SharePointColumnIfNotExistsAdd-SharePointLookupColumn (for cross-list references)Discovering sites and lists (Steps 7โ8) needs a SharePoint connection ID on every CLI version: pa connection list-datasets and list-tables don't find or create connections the way pa app add data-source does on CLI 1.3.0+ (see connector-reference.md).
/list-connections skill, filtered with --search sharepointonline.```bash
pa connection create --connector shared_sharepointonline --use-sso
```
It creates the connection silently with the user's account and prints Connection ID: <id>.
List available SharePoint sites the user has access to:
pa connection list-datasets --connector sharepointonline -c <connection-id>
Present the sites to the user and ask which one(s) they want to connect to. If the user already specified a site URL, confirm it appears in the list.
If pa connection list-datasets fails or returns no results:
pa auth login (or power-apps login on power-apps-only projects), then retry.For each selected site, list the available lists and document libraries:
pa connection list-tables --connector sharepointonline -c <connection-id> -d '<site-url>'
If pa connection list-tables fails or returns no results:
Present the tables to the user and ask which ones they want to add. Suggest tables that look relevant to their use case (based on memory bank context or the user's stated requirements). If lists were created in Step 5, they should appear here.
SharePoint supports both tables and actions, so say which one you're adding. Pass the connection ID from Step 6, so the add doesn't need to look for a connection (on CLI 1.3.0+, also pass --non-interactive):
# Lists and libraries as tables: -c (connection ID), -d (site URL), and --table (list name)
pa app add data-source --connector sharepointonline -c <connection-id> -d '<site-url>' --table '<table-name>'
# Document library and file operations (CLI 1.2.0+): add the connector's actions
pa app add data-source --connector sharepointonline -c <connection-id> --as action
Run the table command for each list or library the user selected. The -d (dataset) is the SharePoint site URL from Step 7, --table is the list/library display name from Step 8. Add the actions only if the app needs file or folder operations; the CLI keeps them as a separate data source next to the tables.
Read sharepoint-reference.md before writing any SharePoint code -- column encoding, choice fields, and lookups have critical gotchas.
What the CLI generates depends on how you added SharePoint in Step 9 (CLI 1.3.0):
| Added with | Generated service | How you call it |
|---|---|---|
--table '<list>' | One service per list, named after it (for example ProjectMilestonesService), with <List>Read / <List>Write models | getAll(options?), get(id), create(record), update(id, changedFields), delete(id) |
--as action | SharePointService | The connector's operations, with positional parameters: GetItems(dataset, table, ...), PostItem(dataset, table, item), ListRootFolder(dataset), ListFolder(dataset, id), GetFileContent(dataset, id), and more |
These examples were verified against CLI 1.3.0. Grep src/generated/services/ to confirm the service name and each method's exact signature before using it, especially in projects created with an older CLI.
Common operations:
// Lists added as tables: one typed service per list
const result = await ProjectMilestonesService.getAll({ top: 50, orderBy: ["Title asc"] });
const milestones = result.data ?? [];
await ProjectMilestonesService.create({ Title: "New milestone" });
await ProjectMilestonesService.update(id, { Title: "Renamed milestone" });
// Connector actions (added with --as action) take positional parameters, for example
// PostItem(dataset, table, item): dataset is the full site URL, table is the list's display name.
const dataset = "https://contoso.sharepoint.com/sites/your-site";
const items = await SharePointService.GetItems(dataset, "Your List Name");
await SharePointService.PostItem(dataset, "Your List Name", { Title: "New Item", Status: "Active" });
// Files in document libraries
const root = await SharePointService.ListRootFolder(dataset);
const files = await SharePointService.ListFolder(dataset, "<folder-id>");
const content = await SharePointService.GetFileContent(dataset, "<file-id>");
Key points:
dataset (action calls) is always the full SharePoint site URLtable (action calls) and --table (Step 9) take the list's display name_x0020_, special chars encoded)Use Grep to find specific methods in the generated services (generated files can be very large -- see connector-reference.md).
npm run build
Fix TypeScript errors before proceeding. Do NOT deploy yet.
Update memory-bank.md with: connector added, site URL, lists/libraries configured (or created), build status. Don't record the connection ID.