Define a macro that eliminates this repetitive pattern:
(-> (from :users) (when active-only (where (:= :active 1))) (when sort-by-name (order-by :name)))

Issue: Macro call that should be transformed by ->

Macro definition:
(defmacro -> (value &rest forms)
  "Smart threading macro that dispatches based on clause types returned by forms.

   This macro enables immutable query composition by threading clauses through
   query-state objects. Creates a single copy at the beginning, then destructively
   adds clauses for efficiency. Supports both v1 select-statements and composer query-states.

   Forms that evaluate to NIL are skipped, enabling conditional composition:
     (-> (from :users)
         (when active-only (where (:= :active 1)))
         (when sort-by-name (order-by :name)))

   Examples:
     ;; With composer clause
     (-> (from :users)
         (where (:= :active 1))
         (order-by :name))

     ;; With v1 select-statement (backward compatible)
     (-> (select (:id :name) (from :users))
         (where (:= :active 1))
         (order-by :name))

     ;; Conditional composition
     (-> (from :users)
         (when include-inactive (where (:= :active 0)))
         (when sort-by-date (order-by :created_at)))"
  (a:with-gensyms (threaded-var clause-var)
    `(let* ((,threaded-var ,value)
            ;; Convert to query-state and copy once at the beginning
            (,threaded-var
              (typecase ,threaded-var
                (query-state-base (copy-query-state-immutable ,threaded-var))
                (stmt:select-statement (select-statement-to-query-state ,threaded-var))
                (stmt:insert-into-statement (insert-statement-to-query-state ,threaded-var))
                (stmt:update-statement (update-statement-to-query-state ,threaded-var))
                (stmt:delete-from-statement (delete-statement-to-query-state ,threaded-var))
                (otherwise (add-clause (make-select-query-state) ,threaded-var)))))
       ;; Now destructively add clauses (no more copying), skipping NILs
       ,@(loop for form in forms
               collect `(let ((,clause-var ,(if (listp form)
                                                ;; For list forms, call the function with its arguments (no threading)
                                                `(,(car form) ,@(cdr form))
                                                ;; For symbol forms, call the function with no arguments
                                                `(,form))))
                          (when ,clause-var
                            (add-clause ,threaded-var ,clause-var))))
       ,threaded-var)))

Macroexpansion:
(let* ((#:threaded-var141 (from :users)) (#:threaded-var141 (typecase #:threaded-var141 (query-state-base (copy-query-state-immutable #:threaded-var141)) (stmt:select-statement (select-statement-to-query-state #:threaded-var141)) (stmt:insert-into-statement (insert-statement-to-query-state #:threaded-var141)) (stmt:update-statement (update-statement-to-query-state #:threaded-var141)) (stmt:delete-from-statement (delete-statement-to-query-state #:threaded-var141)) (otherwise (add-clause (make-select-query-state) #:threaded-var141))))) (let ((#:clause-var142 (when active-only (where (:= :active 1))))) (when #:clause-var142 (add-clause #:threaded-var141 #:clause-var142))) (let ((#:clause-var142 (when sort-by-name (order-by :name)))) (when #:clause-var142 (add-clause #:threaded-var141 #:clause-var142))) #:threaded-var141)