Skip to content

Guide build-plugin on pre-request auth scripts#93

Open
andrewmumblebee wants to merge 2 commits into
mainfrom
work/ah/build-plugin-pre-request-script
Open

Guide build-plugin on pre-request auth scripts#93
andrewmumblebee wants to merge 2 commits into
mainfrom
work/ah/build-plugin-pre-request-script

Conversation

@andrewmumblebee

@andrewmumblebee andrewmumblebee commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

📋 Summary

Adds guidance to the build-plugin skill for the new preRequestScript capability arriving with WebAPI base plugin 1.8.0 (squaredup/squaredup-plugin-repository#1966, SAAS-8337) and its saas-side deploy support, so an agent building a plugin for an API with a custom auth flow (token exchange, per-request HMAC signing) has a supported path.

  • New "Pre-request scripts (custom auth flows)" reference section in references/metadata.md, co-located with the auth patterns: when to reach for a script (prefer built-in authModes first), wiring via scriptingVariables and the dataStreams/scripts/preRequest/<plugin>.js file reference, the reserved scriptState property, the script's variable scope, and a token-exchange example with state-cached expiry drawn from the real N-Able script in the upstream PR.
  • Context pointers only elsewhere (single source of truth): Phase 1's auth step in SKILL.md, the scaffold file tree, and the post-request-scripts section of references/data-streams.md.
  • Skill version bumped to 0.0.12.

Note: end-to-end this depends on both upstream PRs shipping — WebAPI 1.8.0 and the saas file-reference inlining.


🔍 Scope of change

  • Documentation only
  • Repository metadata or configuration
  • CI / automation
  • Other (please describe):

📚 Checklist

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Documentation
    • Added guidance for configuring pre-request scripts to support custom authentication flows.
    • Documented script inputs, outputs, allowed request modifications, encrypted state persistence, available runtime objects, and scripting variables.
    • Included an end-to-end token exchange example with cached token handling.
    • Clarified how datasource-level scripts run before requests and updated the documented build-plugin version.

WebAPI base plugin 1.8.0 (squaredup-plugin-repository PR #1966,
SAAS-8337) adds datasource-level pre-request scripting so plugins can
handle custom auth flows no authMode expresses — token-exchange steps
and per-request HMAC signing. The matching saas change lets a
declarative plugin's base.config reference the script as a file under
dataStreams/scripts/preRequest/, inlined at deploy time.

The build-plugin skill had no coverage of this, so an agent building a
plugin for such an API had no supported path. Add a reference section
beside the auth patterns in metadata.md covering when to reach for a
script (and to prefer built-in authModes first), the wiring including
scriptingVariables and the reserved scriptState property, the script's
variable scope, and a token-exchange example with state-cached expiry
drawn from the PR's real N-Able script. Phase 1's auth step and the
post-request-scripts section point at it, keeping the full material in
one place per the skill-writing guidance.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The build-plugin documentation now describes custom authentication pre-request scripts, their configuration and runtime behavior, execution timing, token caching example, and optional scaffolding. The skill version and authentication planning guidance were updated accordingly.

Changes

Custom authentication documentation

Layer / File(s) Summary
Pre-request script reference
.claude/skills/build-plugin/references/metadata.md, .claude/skills/build-plugin/references/data-streams.md
Documents preRequestScript, scriptingVariables, scriptState, runtime objects, mutable request fields, token caching, and execution before HTTP requests.
Build-plugin workflow guidance
.claude/skills/build-plugin/SKILL.md
Bumps the documented skill version to 0.0.12, adds pre-request planning guidance for custom authentication, and documents optional preRequest/my-plugin.js scaffolding.】【。
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly summarizes the main change: adding guidance for pre-request auth scripts in build-plugin.
Description check ✅ Passed The description is detailed and covers summary, scope, checklist, and implementation context for the documentation-only change.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown

🧩 Plugin PR Summary

ℹ️ No plugins were modified in this PR.

@andrewmumblebee andrewmumblebee marked this pull request as ready for review July 16, 2026 07:27
@andrewmumblebee andrewmumblebee requested a review from a team July 16, 2026 07:27

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.claude/skills/build-plugin/references/metadata.md:
- Around line 245-251: Add timeout or cancellation handling to the auth fetch in
the pre-request hook, using an AbortSignal or the platform’s documented fetch
timeout mechanism. Ensure hung auth requests terminate within a defined limit so
plugin streams and imports cannot stall indefinitely.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI (base), Organization UI (inherited)

Review profile: ASSERTIVE

Plan: Pro

Run ID: 1f6180fa-4098-414a-b307-ea301e879c1c

📥 Commits

Reviewing files that changed from the base of the PR and between 9dafcf7 and e9ed698.

📒 Files selected for processing (3)
  • .claude/skills/build-plugin/SKILL.md
  • .claude/skills/build-plugin/references/data-streams.md
  • .claude/skills/build-plugin/references/metadata.md

Comment on lines +245 to +251
const resp = await fetch(authUrl, {
method: "post",
headers: {
Accept: "application/json",
Authorization: `Bearer ${secrets.signedJwt}`,
},
});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Map the target file and inspect relevant surrounding lines.
wc -l .claude/skills/build-plugin/references/metadata.md
sed -n '220,280p' .claude/skills/build-plugin/references/metadata.md

# Search for related mentions of auth fetch, timeout, cancellation, and WebAPI 1.8.0.
rg -n "authUrl|signedJwt|fetch\\(|timeout|cancell|WebAPI 1\\.8\\.0|plugin request|before every plugin request" .claude/skills/build-plugin -S

Repository: squaredup/plugins

Length of output: 6217


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Inspect any adjacent docs that define the auth flow or runtime constraints.
fd -a "metadata.md" .claude/skills/build-plugin
fd -a "README.md" .claude/skills/build-plugin
fd -a "*.md" .claude/skills/build-plugin | sed -n '1,120p'

Repository: squaredup/plugins

Length of output: 509


Bound the auth fetch. This pre-request hook runs before every plugin request, so a hung auth endpoint can stall streams and imports. Add a timeout/cancellation path, or document the platform timeout for fetch in WebAPI 1.8.0.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.claude/skills/build-plugin/references/metadata.md around lines 245 - 251,
Add timeout or cancellation handling to the auth fetch in the pre-request hook,
using an AbortSignal or the platform’s documented fetch timeout mechanism.
Ensure hung auth requests terminate within a defined limit so plugin streams and
imports cannot stall indefinitely.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant