Agent - Weekly Storage Report

AI & HCI
맥북을 꺼둬도 Google 서버의 스크립트가 용량을 재고, Claude가 매주 두 계정의 변화를 요약해 알려주는 클라우드 자동화
Posted on Oct. 2, 2026, 7:44 a.m. by SANGJIN
random_image

Moved a weekly Google Drive storage check off my laptop and into the cloud. The original version was a Claude (Cowork) scheduled task that ran du and find against locally synced Drive folders, so it only worked while my MacBook was on. The new version measures each Drive where the data actually lives and never touches my computer.

Component Runs on Responsibility
Google Apps Script (one per account) Google servers, weekly time-driven trigger Lists every owned file via Drive API v3, sums sizes per top-level folder, builds Top 10 folders/files, compares with last week, saves .md + .json
Claude scheduled task Cloud only, no local folders Finds both accounts' latest reports via the Google Drive connector and posts a short summary with a push notification

Key design decisions

  • Deterministic math in code, summary in the LLM — The Drive connector does expose per-file size and parent ID, but folder totals require paging through every file and walking parent chains. That job went to a script; Claude only reads the finished report.
  • One script per Google account — The Claude connector is linked to a single account. Running the script inside each account sidesteps that limit, and the second account auto-shares its report folder with the first.
  • Same code for both accounts — The script detects the running account's email and picks its own label (A_Drive / B_Drive) and sharing target, so there's no per-account config to drift.
  • Week-over-week deltas computed by the script — Each run saves a machine-readable JSON next to the Markdown report; the next run diffs top-level folders against it. Reports older than 8 weeks are trashed.
  • Staggered schedule, old task kept as fallback — Apps Script runs in the 18:00 hour on Saturdays and Claude reads at 19:56, since time-driven triggers fire anywhere inside their hour. The original local task was disabled, not deleted.

Verified by running the logic against mocked Apps Script APIs in Node.js, then running it on both real accounts successfully.

Tech: Google Apps Script (V8), Google Drive API v3 (Advanced Service), Claude scheduled tasks, Google Drive connector, JavaScript

====

매주 Google Drive 용량을 체크하는 작업을 내 노트북에서 클라우드로 옮겼다. 원래는 Claude(Cowork) 예약 작업이 로컬 동기화 폴더에 du, find를 돌리는 방식이라 맥북이 켜져 있어야만 동작했다. 지금은 데이터가 원래 있는 Google Drive에서 바로 용량을 재고, 내 컴퓨터는 흐름에 전혀 등장하지 않는다.

구성 요소 실행 위치 역할
Google Apps Script (계정별 1개) Google 서버, 주간 시간 기반 트리거 Drive API v3로 내 소유 파일 전체 수집, 최상위 폴더별 합산, 폴더/파일 Top 10, 지난주 대비 증감 계산, .md + .json 저장
Claude 예약 작업 클라우드 전용 (로컬 폴더 없음) Google Drive 커넥터로 두 계정의 최신 리포트를 찾아 읽고, 요약해서 푸시 알림

핵심 설계 결정

  • 계산은 코드에, 요약은 LLM에 — 커넥터로도 파일별 크기와 상위 폴더 ID는 받을 수 있다. 하지만 폴더 용량을 내려면 전체 파일을 페이지 단위로 받아 부모 폴더를 따라 올라가며 더해야 한다. 이 일은 스크립트에 맡기고, Claude는 완성된 리포트만 읽는다.
  • 계정마다 스크립트 하나씩 — Claude 커넥터는 한 계정에만 연결돼 있다. 각 계정 안에서 스크립트를 돌리는 방식으로 이 제약을 피했고, 두 번째 계정은 리포트 폴더를 첫 번째 계정에 자동 공유한다.
  • 두 계정에 같은 코드 — 실행 계정의 이메일을 보고 라벨(A_Drive / B_Drive)과 공유 대상을 스스로 정한다. 계정별로 설정을 따로 고칠 일이 없다.
  • 지난주 대비 증감도 스크립트가 계산 — 사람이 읽는 마크다운 옆에 기계가 읽는 JSON을 함께 저장하고, 다음 실행 때 최상위 폴더 단위로 비교한다. 8주가 지난 리포트는 휴지통으로 보낸다.
  • 실행 시간을 어긋나게, 기존 작업은 보험으로 — 시간 기반 트리거는 지정한 1시간 안 어딘가에서 실행된다. 그래서 Apps Script는 토요일 18시대, Claude는 19:56에 읽도록 했다. 기존 로컬 작업은 지우지 않고 비활성화만 했다.

Node.js에서 Apps Script API를 가짜로 만들어 로직을 먼저 검증한 뒤, 실제 두 계정에서 정상 실행되는 것을 확인했다.

사용 기술: Google Apps Script (V8), Google Drive API v3 (고급 서비스), Claude 예약 작업, Google Drive 커넥터, JavaScript

  • Velog: https://velog.io/@kosang234/%EC%BB%B4%ED%93%A8%ED%84%B0%EB%A5%BC-%EA%BA%BC%EB%8F%84-%EB%8F%84%EB%8A%94-Google-Drive-%EC%9A%A9%EB%9F%89-%EB%A6%AC%ED%8F%AC%ED%8A%B8-Apps-Script%EC%99%80-Claude-%EC%98%88%EC%95%BD-%EC%9E%91%EC%97%85%EC%9C%BC%EB%A1%9C-%ED%81%B4%EB%9D%BC%EC%9A%B0%EB%93%9C-%EC%9E%90%EB%8F%99%ED%99%94%EB%A5%BC-%EB%A7%8C%EB%93%A4%EB%A9%B4%EC%84%9C-%EA%B9%A8%EB%8B%AC%EC%9D%80-%EA%B2%83%EB%93%A4
Leave a Comment: