frontend-connect
Skill1 starsChanged 24 days agoMITView on GitHub
Use when the person wants a Next.js app that signs in against their local Drupal backend. It creates the app with create-next-app, lays the skill's app files over it, pins the login packages and writes the .env.local file. Also use it to lay the skill's app files over an app it already made, or when that script fails.
- Reads credentials
In this repository3 other files it gives its agents.
- backend-setupSkill
- machine-checkSkill
- safe-deleteSkill
The file
We split this skill into the rules it gives an agent
4 rules. About 0 are common, 2 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 12
Run the machine-check skill first: bash scripts/check-machine.sh in that skill.
- Distinctive: line 19
Run this skill's script with absolute paths:
- Very specific: line 38
No Drupal host sits in the app's source.
- Distinctive: line 60
After you fix the cause, run the script again on the same folder.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Frontend connect
This skill gives the person a Next.js app wired to their Drupal backend for sign-in. The backend is a site made by the backend-setup skill.
Before you start
- Run the machine-check skill first:
bash scripts/check-machine.shin that skill. Go on only when its JSON saysreadyis true. Otherwise, show the person what it reports and stop. - Node.js 24 LTS or later and
mkcertmust be installed. The script checks both. - The backend must be running, and it must carry the Simple OAuth client
nextjswith redirect URIhttp://localhost:3000/api/auth/callback. A backend made by backend-setup at its default template ref has it. - Propose an app folder beside the backend folder, for example
<backend-folder>-app. It must not exist yet, or must be empty. Tell the person the path and wait for their agreement before you run the script.
Create the app
Run this skill's script with absolute paths:
bash <this-skill-folder>/scripts/setup-frontend.sh --backend <backend-project-folder> <app-folder>The script does these steps in order:
- It checks Node, npm, mkcert and that the backend answers.
- It runs
create-next-app@16.4.1with explicit flags (TypeScript, App Router, ESLint, Tailwind, nosrc/, npm). Next.js 16.4.1 is the security floor. - It copies this skill's
assets/appfolder over the new app. - It installs
openid-clientandiron-sessionat exact versions. - It sets the
devscript sonpm run devexportsNODE_EXTRA_CA_CERTSfrommkcert -CAROOTbeforenext dev. Node rejects DDEV's mkcert certificate without it and reads the variable only at launch. npm runs scripts throughsh, so this does not work under plain Windows cmd. - It writes
.env.localonce, withDRUPAL_BASE_URL,DRUPAL_CLIENT_ID,DRUPAL_SCOPE,APP_URLand a randomSESSION_SECRET. - It stops unless git confirms
.env.localis ignored. - It prints
App folder:,Backend URL:, the start command and the next steps. Give them to the person.
npm may report "high severity vulnerabilities". They come from the lint tooling create-next-app adds (eslint-config-next, through braces), not the running app. Leave them, and never run npm audit fix --force: it breaks the pinned versions.
No Drupal host sits in the app's source. To point the app at another backend, edit DRUPAL_BASE_URL in .env.local only.
Running the script again on an app it made skips create-next-app and the install, copies the app files over the app again, and never touches .env.local.
The next step
Tell the person, in plain words: open the backend's login link, run npm run dev, click Sign in, then tell you what the app needs to store.
Sign-in and logout
Sign-in uses Drupal's own login form. To sign in, open the backend's login link first, or run ddev drush uli in the backend folder for a new one if it expired. Then click Sign in. The nextjs client skips the consent screen, so a person logged in to Drupal goes straight through with no password.
Logout drops the tokens from the app's session and then sends the person to Drupal's logout page, which asks for one confirm click. That ends the Drupal login. Logout ends on Drupal's sign-in page, which is expected; the person goes back to the app's address, http://localhost:3000, to sign in again.
In code you write for the app, signed in means the session holds an access token, never just a name. Use isSignedIn in lib/auth-state.ts.
Token refresh is safe within one server process only, such as npm run dev or a single next start; with several processes or serverless instances, two refreshes at once can sign the person out.
Simple OAuth has no revoke endpoint, so a token already issued stays valid for up to 300 seconds after logout, and a refresh token until its lifetime ends. Tell the person this if they ask how final a logout is.
When a step fails
After you fix the cause, run the script again on the same folder.
- Node.js is older than 24: install Node.js 24 LTS or later through the machine-check skill's advice.
- The backend did not answer: run
ddev startin the backend folder. - The folder exists and is not empty: pick another folder, or ask the person.
create-next-appornpm installfails: show the person the output. A partly made app folder is not a valid rerun target untilpackage.jsonlistsopenid-client; remove it with the person's agreement and run again..env.localis not ignored by git: add.env.localto the app's.gitignore, then run again.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

