Token导航 LogoToken导航TokenDH.com
开发操作浏览器github未标认证来源可访问许可证需确认审计异常

appscriptappscript 命令行

Agent Skill

appscript 用于处理 GitHub 仓库、Issue、Pull Request 和代码协作信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要围绕仓库状态、代码变更或协作事项进行整理时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

699

周安装

28

GitHub Stars

公开资料未说明

下载量

226
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:appscript(appscript 命令行)
来源仓库:https://github.com/smkeramati/appscript
仓库路径:skills/appscript
安装命令:
npx skills add https://github.com/smkeramati/appscript --skill appscript
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/smkeramati/appscript --skill appscript

简介

appscript 用于处理 Google Apps Script 项目,支持终端环境下的开发、编辑和部署,适合在 Codex、Claude、Cursor、Gemini CLI 中需要围绕脚本生命周期进行管理时使用。

  • 提供完整的开发流程:创建/克隆、本地编辑、推送、测试和部署,无需浏览器复制粘贴,适用于自动化任务和集成操作。
  • 通过 npx skills add 命令从指定 GitHub 仓库安装,需确认权限范围和维护状态,避免触发联网、命令执行或文件读写。
  • 建议结合来源仓库和原始 README 核验具体用法,确保与宿主环境兼容,并在使用前验证 API 调用和配置选项的有效性。
  • appscript 属于开发类 Skill,可作为该场景下的辅助能力补充。

SKILL.md

appscript — Google Apps Script via clasp

Develop, edit, and deploy Google Apps Script projects from the terminal. Full lifecycle: create/clone → edit locally → push → test → deploy. No browser copy-paste.

Quick Start

# Verify clasp is installed (needs Node 22+)
clasp --version
npm install -g @google/clasp   # install if missing

# One-time: enable Apps Script API in your Google account
# https://script.google.com/home/usersettings → toggle ON
# Without this, every clasp command fails with an authorization error.

clasp login                                    # authenticate (opens browser)
clasp create-script --title "My Script"        # start a new standalone project
# — or —
clasp clone-script <scriptId>                  # clone existing project
# scriptId: script.google.com → gear icon → Script ID

Edit your .gs files locally, then clasp push. That's the core loop.


Script Types: Bound vs. Standalone

This distinction matters for how you create, clone, and access data.

Standalone scripts — Created via script.google.com or clasp create-script. Live independently in Drive. Access Google services through explicit IDs (e.g., SpreadsheetApp.openById('...')).

Container-bound scripts — Created via "Extensions → Apps Script" from inside a Sheet, Doc, Form, or Slide. Tightly coupled to the parent file. Can call SpreadsheetApp.getActiveSpreadsheet() with no arguments because GAS knows which file the script belongs to. Triggers like onEdit(e) only work for bound scripts.

To work locally on a bound script:

  1. Open the Sheet/Doc → Extensions → Apps Script
  2. Gear icon (Project Settings) → copy the Script ID
  3. clasp clone-script <scriptId> — now you have local files

Key behavioral difference:

// Bound script — works without an ID
const ss = SpreadsheetApp.getActiveSpreadsheet();

// Standalone script — must supply the ID
const ss = SpreadsheetApp.openById('1BxSheet...');

Project Structure

my-project/
├── .clasp.json           ← project config (scriptId, rootDir)
├── .claspignore          ← gitignore-style exclusions from push
├── appsscript.json       ← manifest (must exist and be pushed)
├── Code.gs               ← main logic
├── Utils.gs              ← helpers
└── ui.html               ← HTML for web apps / sidebars

All .gs files share a global scope — there are no modules, no import/export. A function defined in Utils.gs is automatically available in Code.gs. File load order matters for top-level declarations; control it with filePushOrder in .clasp.json if needed.

Always use V8 runtime in appsscript.json. V8 unlocks ES6+ (arrow functions, async/await syntax, destructuring). Without it you're on ES5 Rhino.

{
  "timeZone": "America/New_York",
  "exceptionLogging": "STACKDRIVER",
  "runtimeVersion": "V8"
}

Daily Workflow

clasp show-file-status          # preview what will push/pull (dry run)
clasp push                      # upload local → Google
clasp push --watch              # auto-push on every file save
clasp push --force              # skip confirmation prompts

clasp pull                      # download Google → local
clasp pull --versionNumber 3    # pull a specific version

Running & Debugging

# Execute a function remotely
clasp run-function myFunction
clasp run-function processData --params '["arg1", 42]'

# Stream Cloud Logging
clasp tail-logs
clasp tail-logs --watch         # continuous
clasp tail-logs --json          # machine-readable

# Debug clasp itself
DEBUG=clasp:* clasp push

clasp run-function requires the project to be deployed as an API Executable or have a GCP project linked with Apps Script API enabled. Without that setup, push and test directly via the Apps Script editor at script.google.com, or trigger from a linked Sheet.


Versions & Deployments

Versions are immutable snapshots. Deployments point to a version and expose the script externally.

clasp create-deployment --description "v1.0 initial release"
clasp create-deployment --versionNumber 3 --description "hotfix"

clasp list-deployments
clasp update-deployment <deploymentId> --versionNumber 4 --description "v1.1"
clasp delete-deployment <deploymentId>
clasp delete-deployment --all

Deployment types (configured in appsscript.json):

  • Web AppdoGet(e) / doPost(e) required; accessible via a public URL
  • API Executable — enables clasp run-function from external callers
  • Add-on — distributable via Google Workspace Marketplace

Authentication

clasp login                              # standard OAuth (opens browser)
clasp show-authorized-user               # confirm active account
clasp logout

# Multiple accounts
clasp login --user work
clasp login --user personal
clasp push --user work                   # specify per command

# CI/CD (no browser)
clasp login --adc                        # uses GOOGLE_APPLICATION_CREDENTIALS
clasp login --creds client_secret.json   # org GCP project OAuth

API Management

clasp enable-api sheets                  # enable Sheets API for this project
clasp list-apis                          # see available and enabled APIs
clasp disable-api drive

TypeScript

Clasp v3 removed built-in TypeScript transpilation. The recommended pattern is to compile externally and push the output.

Setup:

npm install --save-dev typescript rollup @rollup/plugin-typescript @types/google-apps-script

rollup.config.js:

import typescript from '@rollup/plugin-typescript';
export default {
  input: 'src/index.ts',
  output: { file: 'dist/Code.js', format: 'esm' },
  plugins: [typescript()]
};

.clasp.json — point rootDir at the compiled output:

{ "scriptId": "...", "rootDir": "dist/" }

Build and push:

npx rollup -c && clasp push

Type hints without TypeScript — install types for autocomplete in VS Code:

npm install --save-dev @types/google-apps-script

GAS Libraries

Libraries let you share code between GAS projects without copying files.

Using a library:

  1. Get the library's Script ID from its author
  2. Add to appsscript.json:
{
  "dependencies": {
    "libraries": [
      {
        "userSymbol": "MyLib",
        "libraryId": "1T03atLib...",
        "version": "3"
      }
    ]
  }
}
  1. Access it as MyLib.functionName() in your code

Creating a library:

  1. Write your script as normal
  2. Deploy as a "Library" type (in the script editor: Deploy → New Deployment → Library)
  3. Share the Script ID with consumers; they add a version number after each new deployment

Note: libraries add ~50ms of overhead per function call since GAS resolves them at runtime. For performance-critical hot paths, inline the code instead.


GAS Code Quality

Batch all Sheets operations

Every call to a Google service (Sheets, Drive, Gmail, etc.) is an HTTP round-trip costing ~100–500ms. In a loop, 100 individual cell reads become 100 serial requests — often enough to hit the 6-minute execution timeout. Read and write in bulk instead.

100 API calls — slow, risks timeout:

for (let i = 1; i <= 100; i++) {
  const val = sheet.getRange(i, 1).getValue();
  sheet.getRange(i, 2).setValue(val * 2);
}

2 API calls — fast:

const vals = sheet.getRange('A1:A100').getValues();   // one read
const result = vals.map(([v]) => [v * 2]);
sheet.getRange('B1:B100').setValues(result);           // one write
SpreadsheetApp.flush();   // commit buffered writes before any subsequent read

SpreadsheetApp.flush() is needed because GAS buffers writes. Skipping it means a read immediately after a write may return stale data.

Language limits

// ✅ Works in V8
const fn = (x) => x * 2;
const [a, ...rest] = array;

// ⚠️ async/await syntax works in V8, BUT GAS has no event loop
// Only use it if you have a real native Promise to await.
// setTimeout, setInterval, and browser I/O never fire — there's no scheduler.
async function example() {
  const result = await someNativePromise;   // ok
  // await fetch(...) — won't work, use UrlFetchApp.fetch() instead
}

// ❌ Never works in GAS (any runtime)
import { foo } from './utils.js'   // no ES modules — global scope only
export default function() {}
fetch('https://api.example.com')   // use UrlFetchApp.fetch() instead
setTimeout(() => {}, 1000)         // no timer callbacks
window / document / localStorage   // no DOM or browser APIs

// ❌ V8 parse error — avoid
class Foo { #privateField = 1; }   // private class fields not supported

Store config in PropertiesService

Hardcoding API keys or settings in .gs files means they're pushed to Google and visible to script editors. Store them in PropertiesService instead — it persists across deployments and stays out of source files.

// Write once (e.g., a setup function)
PropertiesService.getScriptProperties().setProperty('API_KEY', 'your-secret');

// Read anywhere
const key = PropertiesService.getScriptProperties().getProperty('API_KEY');

Common Patterns

Web app (HTTP handler):

function doGet(e) {
  return HtmlService.createHtmlOutputFromFile('ui').setTitle('My App');
}
function doPost(e) {
  const data = JSON.parse(e.postData.contents);
  // process...
  return ContentService.createTextOutput(JSON.stringify({ ok: true }))
    .setMimeType(ContentService.MimeType.JSON);
}

Time-based trigger:

function setupTrigger() {
  ScriptApp.newTrigger('myFunction').timeBased().everyHours(1).create();
}
// To remove all triggers:
ScriptApp.getProjectTriggers().forEach(t => ScriptApp.deleteTrigger(t));

External HTTP request:

const res = UrlFetchApp.fetch('https://api.example.com/data', {
  method: 'post',
  contentType: 'application/json',
  payload: JSON.stringify({ key: 'value' }),
  headers: { Authorization: 'Bearer ' + token }
});
const json = JSON.parse(res.getContentText());

Cache expensive fetches (up to 6 hours):

const cache = CacheService.getScriptCache();
let data = cache.get('mykey');
if (!data) {
  data = JSON.stringify(UrlFetchApp.fetch('https://api.example.com').getContentText());
  cache.put('mykey', data, 1500);   // 25 minutes
}
return JSON.parse(data);

Rate limit protection with sleep:

// When hitting APIs that throttle (e.g. UrlFetch returning 429)
items.forEach((item, i) => {
  processItem(item);
  if (i % 10 === 9) Utilities.sleep(1000);   // pause 1s every 10 calls
});

Gemini AI (via Ai service — GAS native):

// Available in GAS without any API key setup — uses project's linked GCP
function summarizeText(text) {
  const model = Ai.getGenerativeModel({ model: 'gemini-2.0-flash' });
  const result = model.generateContent(text);
  return result.response.text();
}

Note: Ai service requires the project to have a linked GCP project with the Vertex AI or Generative Language API enabled. Alternatively, call the Gemini REST API via UrlFetchApp.fetch() with your own API key.


Troubleshooting

ErrorCauseFix
Apps Script API has not been usedAPI not enabled in accounthttps://script.google.com/home/usersettings → enable
Could not find.clasp.jsonNot in project rootcd to project directory
Authorization requiredOAuth scopes changed in manifestRe-push, then re-authorize in the script editor
Script timeoutExceeded 6-min execution limitSplit into smaller batches; chain via triggers
Service using too much computer timeDaily quota hitUse batch operations; wait 24h; Workspace accounts have higher limits
Stale data after writeWrites are bufferedCall SpreadsheetApp.flush() before reading
Push confirmation loopInteractive terminal promptAdd --force flag
Command not found after upgradeClasp v2 → v3 renamesSee rename table in references/clasp-commands.md
HttpResponseException: 429UrlFetch rate limit hitAdd Utilities.sleep(1000) between calls; batch requests
ReferenceError: X is not definedFile load order issueAdd filePushOrder in .clasp.json

MCP / AI Integration

Use clasp as an MCP server so Claude Code can manage GAS projects directly:

claude mcp add clasp -- npx -y @google/clasp mcp
# Or in Claude Code:
# /plugin install @google/clasp

Reference Files

Load these on demand — don't pre-read them unless you need the detail.

FileLoad when
references/clasp-commands.mdNeed full flag reference for any command, or migrating from clasp v2 (full rename table there)
references/gas-reference.mdNeed daily quotas, all available services, deployment manifest fields, more code patterns, trigger types
references/config-files.mdNeed complete .clasp.json / appsscript.json / .claspignore field reference

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

33%
按下载量换算75

Claude

29.54%
按下载量换算67

Cursor

19.16%
按下载量换算43

Gemini CLI

8.76%
按下载量换算20

安全审计

Gen Agent Trust Hub

通过

Socket

未通过

Snyk

可疑

权限和风险

操作浏览器

该 Skill 可能涉及浏览器控制能力,使用时可能读取或操作网页内容,需要在受控环境中确认权限边界。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。来源安全扫描存在 warning/failed 结果,不能写成本站确认安全。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills